如何找到android中正则表达式的所有匹配项 [英] How can I find all matches to a regular expression in android

查看:826
本文介绍了如何找到android中正则表达式的所有匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到android中正则表达式的所有匹配项。我发现它适用于Perl,Python等但不适用于Android。

How can I find all matches to a regular expression in android. I founds it for Perl, Python etc but not for android.

推荐答案

以下是一个例子:

import java.util.regex.Matcher;
import java.util.regex.Pattern;
...
// Find all the words of "foo bar".
Matcher m = Pattern.compile("\\w+").matcher("foo bar");
while (m.find()) {
    System.out.println("Found: " + m.group(0));
}

这篇关于如何找到android中正则表达式的所有匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆