Reputation: 4428
I have a regex that I am using in an asp.net RegularExpressionValidator to check a TextField.
^(?=.*[a-z])(?=.*\d)(?=.*[A-Z]).{8,}$
The example string I have stumbled on is 'RedCoal1'
Firefox = Matched
IE8 = Matched
Chrome = Matched
IE7 = DOES NOT MATCH
WHY!!!!
Upvotes: 2
Views: 135
Reputation: 536775
The implementation of lookahead in WSH's RegExp as used by IE is just broken. The bug usually pops up in exactly this case, trying to use one regex to verify several things at once.
Plus some older browsers don't support lookahead at all (it wasn't in the original JavaScript spec, though it is now in ECMA-262-3). So all in all it's best to avoid lookahead in browser RegExp.
It would be best to separate out each check (each character class, and length) into manual validation steps.
Upvotes: 6