In Java, what is the most efficient way of removing given characters from a String? Currently, I have this code:
private static String processWord(String x)
Although \\p{Punct} will specify a wider range of characters than in the question, it does allow for a shorter replacement expression:
\\p{Punct}
tmp = tmp.replaceAll("\\p{Punct}+", "");