-3
我正在使用正則表達式從字符串中獲取單詞,它在字母數字的情況下工作正常,但如果使用算術運算符則返回錯誤答案。正則表達式在所有情況下都不能正常工作
Matcher oMatcher;
Pattern oPattern;
String key = "a++";
oPattern = Pattern.compile("\\b" + key + "\\b");
oMatcher = oPattern.matcher("max winzer® build-a-chair cocktailsessel »luisa« in runder form, zum selbstgestalten");
if (oMatcher.find()) {
System.out.println("True");
}
什麼是你想完全匹配?一個模式中的「++」看起來不正確,但是這些加號沒有逃脫。 –
a ++是一些東西的代碼。 –