title: Javascript regex .test() "Uncaught TypeError: undefined is not a function"
body: <p>Just trying to use javascript's regex capabilities with the <code>.test()</code> function.</p>
  
  <pre><code>  var nameRegex = '/^[a-zA-Z0-9_]{6,20}$/';
  
    if(nameRegex.test($('#username').val())) {
        ...
    }
  </code></pre>
  
  <p>The error is on this line <code>if(nameRegex.test($('#username').val())) {</code></p>
  
  <p>Debugger breaks there and says <strong>"Uncaught TypeError: undefined is not a function"</strong>. It seems like <code>.test()</code> is not defined? Shouldn't it be?</p>