title: Java replace characters with uppercase around (before and after) specific character
body: <p>I have this kind of input</p>
  
  <pre><code>word w'ord wo'rd
  </code></pre>
  
  <p>I need to convert to uppercase both characters at the starts of the word and right after the <code>'</code> character (which can exists multiple times).</p>
  
  <p>The output I need (using the previous example) is</p>
  
  <pre><code>word W'Ord Wo'Rd
  </code></pre>
  
  <p>I tried with a simple pattern</p>
  
  <pre><code>s.replaceAll("(\\w)(\\w*)'(\\w)", "$1");
  </code></pre>
  
  <p>but I'm unable to convert the group 1 and 3 to uppercase</p>
  
  <hr>
  
  <p>EDIT:
  After I discovered a little mistake in the main question, I edited @Wiktor Stribizew code in order to include the case I missed.</p>
  
  <pre><code>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();
  </code></pre>