title: JavaScript RegExp.test() not returning true
body: <p>I am trying to validate that a password matches my specified pattern.  I got the password pattern from <a href="http://html5pattern.com/" rel="nofollow noreferrer">http://html5pattern.com/</a>.  It should validate that my password contains uppercase, lowercase, and a number.  I have checked the string 'Asdf1' on the above site and it works fine.  I also added my regex pattern to W3Schools "Try It Yourself" example and it also returned TRUE.  However when I try to check the string pattern in my code it returns FALSE, as it does in JSFiddle: </p>
  
  <p><a href="https://jsfiddle.net/rnwilis/9okh6ppc/5/" rel="nofollow noreferrer">https://jsfiddle.net/rnwilis/9okh6ppc/5/</a></p>
  
  <p>Here is my named function:</p>
  
  <pre><code>function validatePassword(data){
      var testStr = "Asdf1";
      var pattern = new RegExp('^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$', 'g');      
      var result = pattern.test(testStr);      
      return result;    
  }
  </code></pre>
  
  <p>As you can see, I created a self executing anonymous function in Fiddle.  This is a named function that I will call in my code.  I hard-coded the string just to try to get the expected results. Ultimately testStr = data as I am passing in the user input password to the named function.  I have also tried creating the RegExp object with and without the 'g' tag, which I don't really think makes a difference in this circumstance. </p>