Java equivalent of JavaScript's String.match()

后端 未结 3 545
死守一世寂寞
死守一世寂寞 2021-01-11 13:56

What is the Java equivalent of JavaScript\'s String.match()

I need to get an array or a list of all matches

Example:

var str = \         


        
3条回答
  •  有刺的猬
    2021-01-11 14:23

    Take a look at the Pattern and Matcher classes in the regex package. Specifically the Matcher.find method. That does not return an array, but you can use it in a loop to iterate through all matches.

提交回复
热议问题