title: Replace each matching string with different value in Ruby
body: <p>I have an input string and a pattern. I need to replace each match with a unique value. In C# I would do this:</p>
  
  <pre><code>var result = Regex.Replace(input, pattern, e =&gt; GenerateNewString());
  </code></pre>
  
  <p>How can I do this in Ruby?</p>