什么是Java的Java等价物 String.match()
我需要得到一个数组或所有匹配的列表
例:
var str = 'The quick brown fox jumps over the lazy dog';
console.log(str.match(/e/gim));
Run Code Online (Sandbox Code Playgroud)
给
["e", "e", "e"]
Run Code Online (Sandbox Code Playgroud)
Mac*_*rse 15
检查Regex教程
您的代码应该与此类似:
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));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3758 次 |
| 最近记录: |