title: What is the equivalent of Regex-replace-with-function-evaluation in Java 7?
body: <p>I'm looking for a <em>very simple</em> way of getting the equivalent of something like the following JavaScript code. That is, for each match I would like to call a certain transformation function and use the result as the replacement value.</p>
  
  <pre><code>var res = "Hello World!".replace(/\S+/, function (word) {
      // Since this function represents a transformation,
      // replacing literal strings (as with replaceAll) are not a viable solution.
      return "" + word.length;
  })
  // res =&gt; "5 6"
  </code></pre>
  
  <p>Only .. in Java. And, preferably as a "single method" or "template" that can be reused.</p>