String.replaceAll variation
<p>Is there a quick way to replace all of some pattern occurrences with data derived from the matched pattern?</p>

<p>For example, if I wanted to replace all occurrences of a number within a string with the same number padded to fixed length with 0s.</p>

<p>In this case if the length is 4, then <code>ab3cd5</code> would become <code>ab0003cd0005</code>.</p>

<p>My idea was using a StringBuilder and 2 patterns: one would get all numbers and the other would get everything that is not a number, and appending the matches to the builder by the index the matches were found.</p>

<p>I think there might be something simpler.</p>
