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?
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.
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.
Both version 0.1.3 and 0.1.6 of grunt-html2js were tested.
The issue created at the html2js project resulted in version 0.1.7 that resolved the bug. Thank you karlgoldstein for a quick response and fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With