为什么以下算法不会停止?(str是我正在搜索的字符串,findStr是我想要查找的字符串)
String str = "helloslkhellodjladfjhello";
String findStr = "hello";
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);
Run Code Online (Sandbox Code Playgroud) 有一个字符串变量,其中包含带点的数字数据,例如$x = "OP/1.1.2/DIR";
。数字数据的位置可以在任何情况下由用户通过在应用程序内部修改来改变,斜杠可以由任何其他字符改变;但虚线数字数据是强制性的。那么这里如何1.1.2
从字符串中提取点数数据呢?