我想删除类似于 ' 的标签和 <
pattern=Pattern.compile("'");
match=pattern.matcher(line);
match.replaceAll("");
但它不起作用。我也试过:
line=line.replace("&","");
line=line.replace("apos","");
line=line.replace(";","");
但这一次,它只替换了;分隔符而不是 & 和 apos ....
最佳答案
而不是使用来自 Apache 的正则表达式试用 StringEscapeUtils http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html对于许多类似的目的非常方便
关于java - 替换 Java 中的 ' 和类似标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8699325/