I am trying to replace all punctuation except the - and _ using a method I found here, but I can only get it to work on " using the exact code as posted which used a negative lookahead:
(?!")\\p{punct}
//Java example:
String string = ".\"'";
System.out.println(string.replaceAll("(?!\")\\p{Punct}", ""));
I tried:
name = name.replaceAll("(?!_-)\\p{Punct}", ""); // which just replaces all punctuation.
name = name.replaceAll("(?!\_-)\\p{Punct}", ""); // which gives an error.
Thanks.