title: How to manipulate regex replacement strings in Elixir
body: <p>I found myself wanting to do this in Elixir:</p>
  
  <pre><code>re_sentence_frag = %r/(\w([^\.]|\.(?!\s|$))*)(?=\.(\s|$))/
  Regex.replace(re_sentence_frag, " oh.  a DOG. woOf. ", String.capitalize("\\1"))
  </code></pre>
  
  <p>Of course, that has no effect.  (It capitalizes the string <code>"\\1"</code> just once.)  What I really meant is to apply <code>String.capitalize/1</code> to every match found by the <code>replace</code> function.  But the 3rd parameter can't take a function reference, so passing <code>&amp;(String.capitalize("\\1")</code> also doesn't work.</p>
  
  <p>This seems so fundamental that I'm surprised it's not possible.  Is there another approach that would as neatly express this kind of manipulation?  It looks like the underlying Erlang libraries would not immediately support passing a function reference as the 3rd parameter, so this may not be completely trivial to fix in Elixir.</p>
  
  <p>How would you program manipulation of each matched string?</p>