title: Using captured regex group as argument to method
body: <p>Normally, when using regular expressions I can refer to a captured group using the <code>$</code> operator, like so:</p>
  
  <pre><code>value.replaceAll("([A-Z])", "$1"); 
  </code></pre>
  
  <p>What I want to know is if it is somehow possible to use the captured value in a method call, and then replace the group with the return value of the method, like so:</p>
  
  <pre><code>value.replaceAll("([A-Z])", foo("$1"));
  </code></pre>
  
  <p>Doing it the above way does not work, unsurprisingly the passed in string is not the captured group but the string <code>"$1"</code>. </p>
  
  <p>Is there any way I can use the captured value as an argument to some method? Can it be done?</p>