title: Convert Regular expression to mask-input - Javascript
body: <p>I am trying to convert regular expression format into a mask-input string to guide the user to enter the correct input on the UI. Numbers would be represented by "#" and letter by "A". </p>
  
  <p>Basically,</p>
  
  <pre><code>      "^\d{3}$"                        --&gt;    "###"
        "^(GB)\d{3}$"                    --&gt;    "GB###"
        "^\d{2}\.\d{3}\/\d{4}-\d{2}$"    --&gt;    "##.###/####-##"
        "^\d{2}[ ]\d{3}[ ]\d{3}$"        --&gt;    "## ### ###" 
  </code></pre>
  
  <p>function convertToMaskInput(regex){</p>
  
  <p>}</p>
  
  <pre><code>convertToMaskInput("^\d{4}$");
  //Output: "####"
  </code></pre>
  
  <p>I am beginner to Javascript and I am having hard time to do this dynamically. Any help or guidance is appreciated. </p>
  
  <p>Thanks in advance! </p>