I use ng-pattern to validate my client side if a few cases, like looking at password complexity.
Now, I get really strange matches in my regex using ng-pattern. Look at examples down below
<span class="registration-error" ng-show="regForm.password.$error.pattern">- Fail to match..</span>
<input type="password" ng-model="registerForm.password" name="password" ng-pattern="/^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\d\W]).*$/" required/>
The above should require 8 characters, at least 1 uppercase character and 1 digit or special character. For some reason I get a match on words like FaiLoudD which doesn't make sense.
I run the same regex in my python backend and it works like a charm. I also verified the regex using http://regexpal.com/ and it also works perfect.
Why does ng-pattern match so weird?
Update:
I digged through all modules and the whole building process of my application. The ng-pattern directive started working again when I disabled grunt-html2js in my building process. It seems to have caused ng-pattern to interpret the regex incorrectly. As issue is created at the html2js project. And with that I will close this question.
.*from the beginning of the pattern, because you actually want to have all lookaheads start from the beginning of the string (this should also significantly improve performance).