我要替換這些字符中的任何一個:Java的正則表達式
% \ , [ ] # & @ !^
...空字符串( 「」)。
我用這個代碼:
String line = "[ybi-173]";
Pattern cleanPattern = Pattern.compile("%|\\|,|[|]|#|&|@|!|^");
Matcher matcher = cleanPattern.matcher(line);
line = matcher.replaceAll("");
但它不工作。
我在這個正則表達式中想念什麼?
您可能需要轉義所有特殊字符,而不是`\` – 2011-02-06 18:30:11