How can I find all matches to a regular expression in android

前端 未结 1 392
借酒劲吻你
借酒劲吻你 2020-12-17 18:04

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

相关标签:
1条回答
  • 2020-12-17 18:44

    Here's an example:

    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));
    }
    
    0 讨论(0)
提交回复
热议问题