我正在尝试使用我在此处找到的方法替换除 - 和 _ 之外的所有标点符号,但我只能使用发布的使用负前瞻的确切代码来让它工作:
(?!")\\p{punct}
//Java example:
String string = ".\"'";
System.out.println(string.replaceAll("(?!\")\\p{Punct}", ""));
我试过:
name = name.replaceAll("(?!_-)\\p{Punct}", ""); // which just replaces all punctuation.
name = name.replaceAll("(?!\_-)\\p{Punct}", ""); // which gives an error.
谢谢。