-1
子字符串搜索这是我做过什么:防止重复串JAVA
String[] conjunctions = new String[] {
"after", "although", "as if",
"as long as", "as much as", "as soon as",
"as though", "because", "before", "by the time",
"even if", "even though", "if",
};
for (String toSearch : conjunctions) {
int occurrence = textToAnalyse.split("(?i)\\W" + toSearch +"\\W").length - 1;
System.out.println(toSearch + " X " + occurrence);
}
例如,"if"
和"even if"
将被视为是"if"
同样的事情也会被计算两次。有没有一种方法来优先搜索后者,并阻止JAVA搜索两次?非常感谢
输入:
textToAnalyse = "Even if you are smart, you are still dumb."
预期输出:
even if X 1
if X 0
请正确解释您的问题。添加输入,输出或预期输出。 –