JAVA用正则表达式提取全部符合的内容

举例来说:
一个字符串:“This is easy,It is so easy!”;我要把两个“easy”都提取出来。需要获得的是这两个easy开始的位置,用Matcher.start()只能取得第一个的位置。求高人上代码。

String s="This is easy,It is so easy!";
Pattern pattern=Pattern.compile("easy");
Matcher matcher = pattern.matcher(s);
while (matcher.find()){
    //你的代码
    System.out.println(matcher.start());
}

追问

虽然不是我要的答案,但是我自己解决了~~~

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答