我要替换这些字符中的任何一个:Java的正则表达式
% \ , [ ] # & @ !^
...空字符串( “”)。
我用这个代码:
String line = "[ybi-173]";
Pattern cleanPattern = Pattern.compile("%|\\|,|[|]|#|&|@|!|^");
Matcher matcher = cleanPattern.matcher(line);
line = matcher.replaceAll("");
但它不工作。
我在这个正则表达式中想念什么?
您可能需要转义所有特殊字符,而不是`\` – 2011-02-06 18:30:11