I have this kind of input
word w'ord wo'rd
I need to convert to uppercase both characters at the starts of the word and right after the '
character (which can exists multiple times).
The output I need (using the previous example) is
word W'Ord Wo'Rd
I tried with a simple pattern
s.replaceAll("(\\w)(\\w*)'(\\w)", "$1");
but I'm unable to convert the group 1 and 3 to uppercase
EDIT: After I discovered a little mistake in the main question, I edited @Wiktor Stribizew code in order to include the case I missed.
Matcher m = Pattern.compile("(\\w)(\\w*)'(\\w)").matcher(s);
StringBuffer result = new StringBuffer();
while (m.find()) {
m.appendReplacement(result, m.group(1).toUpperCase() + m.group(2) + "'" + m.group(3).toUpperCase());
}
m.appendTail(result);
s = result.toString();