匹配Java中的所有正则表达式
public class RegexOccur {
public static void main(String args[]) {
String str = "java is fun so learn java";
String findStr = "java";
int lastIndex = 0;
int count = 0;
while(lastIndex != -1) {
lastIndex = str.indexOf(findStr,lastIndex);
if(lastIndex != -1) {
count ++;
lastIndex += findStr.length();
}
}
System.out.println(count);
}
}输出
2
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C编程
C++
C#
MongoDB
MySQL
Javascript
PHP