Create array of regex matches

后端 未结 6 1552
醉话见心
醉话见心 2020-11-22 16:21

In Java, I am trying to return all regex matches to an array but it seems that you can only check whether the pattern matches something or not (boolean).

How can I u

6条回答
  •  死守一世寂寞
    2020-11-22 16:52

    Java makes regex too complicated and it does not follow the perl-style. Take a look at MentaRegex to see how you can accomplish that in a single line of Java code:

    String[] matches = match("aa11bb22", "/(\\d+)/g" ); // => ["11", "22"]
    

提交回复
热议问题