Javascript regex browser mismatch?
I have a regular expression that I am using in asp.net RegularExpressionValidator to validate a TextField.
^(?=.*[a-z])(?=.*\d)(?=.*[A-Z]).{8,}$
An example line I came across is "RedCoal1"
Firefox =
IE8 Compliant
= Chrome Compliant = Compliant
IE7 = NOT A MATCH
WHY!!!!
+2
ACBurk
source
to share
1 answer
The WSH RegExp lookahead implementation used by IE is simply aborted . Usually, the error appears in this case when trying to use one regex to test several things at once.
In addition, some older browsers do not support lookahead at all (this was not in the original JavaScript specification, although it is now in ECMA-262-3). Therefore, it is generally best to avoid viewing in the RegExp browser.
It is best to split each check (each character class and length) into manual check steps.
+6
bobince
source
to share