title: Make JavaScript helper function to match text against the regex dynamically
body: <p>I want to create a JavaScript helper function that will match the string and regex dynamically. </p>
  
  <pre><code>   //Helper function
      function is_mask(str, regax){
          mask = new RegExp(regax, 'i');
          return mask.test( str );
      }
  </code></pre>
  
  <p>So that's the helper function now if I want to call that function I' ll be doing something like this</p>
  
  <pre><code>is_mask('text', 'a-zA-Z'); //Should return true
  </code></pre>
  
  <p>My result is always false. What am I doing wrong over here?</p>