title: Apply mask to a string
body: <p>I am reading a string ID value from a table.  When the ID was input by the user, it was done with an input mask that the user defined, so the mask could have been something like <code>000-00-0000</code>, <code>##-######</code>, <code>AA-9999999</code>, etc.  The mask will vary by user, and so must be evaluated at runtime.</p>
  
  <p>Given that only the alphanumeric text is stored in the table, what is the best way of generating a new string with that mask applied?</p>
  
  <p>For example:</p>
  
  <blockquote>
    <p>Table value = "123456789"</p>
  </blockquote>
  
  <p>If user has defined mask of <code>000-00-0000</code>, I want to get string <code>123-45-6789</code>.</p>
  
  <p>If user has defined mask of <code>AA-9999999</code>, I want to get string <code>12-3456789</code>.</p>
  
  <p>If user has defined mask of <code>FR999_999999</code>, I want to get string <code>FR123_456789</code>.</p>