// Removes whitespace between a word character and . or , String pattern = "(\\w)(\\s+)([\\.,])"; System.out.println(EXAMPLE_TEST.replaceAll(pattern, "$1$3"));
// Extract the text between the two title elements pattern = "(?i)(<title.*?>)(.+?)()"; String updated = EXAMPLE_TEST.replaceAll(pattern, "$2");