java replace all regex code example
Example 1: java string regexp replace
String input = "abcd";
Pattern p = Pattern.compile("regexp");
String output = p.matcher(input).replaceAll("replacement");
Example 2: java replaceall single character
.replaceAll("(?<!\\S)[^ ](?!\\S)", " ").trim()