什么是Java的JavaScript等价物 String.match()
String.match()
我需要获取一个数组或所有匹配项的列表
例:
var str = 'The quick brown fox jumps over the lazy dog'; console.log(str.match(/e/gim));
给
["e", "e", "e"]
http://www.w3schools.com/jsref/jsref_match.asp
检查正则表达式教程
您的代码应类似于以下内容:
String input = "The quick brown fox jumps over the lazy dog"; Matcher matcher = Pattern.compile("e").matcher(input); while ( matcher.find() ) { // Do something with the matched text System.out.println(matcher.group(0)); }