RegularExpressionValidator always fails, but ValidationExpression works in testing
Posted
by Jerph
on Stack Overflow
See other posts from Stack Overflow
or by Jerph
Published on 2010-05-21T21:36:19Z
Indexed on
2010/05/21
21:40 UTC
Read the original article
Hit count: 176
I found the answer to this, but it's a bit of a gotcha so I wanted to share it here.
I have a regular expression that validates passwords. They should be 7 to 60 characters with at least one numeric and one alpha character. Pretty standard. I used positive lookaheads (the (?= operator) to implement it:
(?=^.{7,60}$)(?=.*[0-9].*)(?=.*[a-zA-Z].*)
I checked this expression in my unit tests using Regex.IsMatch(), and it worked fine. However, when I use it in a RegularExpressionValidator, it always fails. Why?
© Stack Overflow or respective owner