正则表达式
作者:互联网
String input = "ABCD1234BCDE"; String mode = "BCD"; Pattern pattern = Pattern.compile(mode); int count = 0; Matcher matcher = pattern.matcher(input); while(matcher.find()) { count++; }
匹配到两次就会退出while循环
注意不能这么写,这么写永远退不出来
while(pattern.matcher(input).find()) { count++; }
标签:count,正则表达式,matcher,while,Pattern,pattern,input 来源: https://www.cnblogs.com/juniorMa/p/15744090.html