- public static void main(String[] args) {
- String oldStr = "woainvshenhehenvshengengaiwo";
-
- String newStr = oldStr.replace("nvshen", "");
-
- System.out.println(newStr);
-
- int begin = 0;
- int count = 0;
- while((begin = oldStr.indexOf("nvshen", begin)) != -1){
- count++;
- begin = begin + "nvshen".length();
- }
-
- System.out.println(count);
-
-
- System.out.println((oldStr.length() - newStr.length())/"nvshen".length());
- }
- }
复制代码
|
|