【问题标题】:Regex matches in JavaJava中的正则表达式匹配
【发布时间】:2012-12-02 00:25:26
【问题描述】:

我对 Java 还很陌生,我正在尝试学习更高级的主题,例如 Regex。

Java 等同于以下 C# 代码:

foreach (Match m in Regex.Matches(input, output)))
    {
...
    }

我有点卡住了。 :/

【问题讨论】:

标签: c# java regex match


【解决方案1】:
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
    String match = matcher.group();
    ...
}

【讨论】:

    猜你喜欢
    • 2011-03-30
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-06
    • 2015-06-03
    相关资源
    最近更新 更多