-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
請正確解釋您的問題。添加輸入,輸出或預期輸出。 –