use (?=) as positive look ahead, and (?!) as negative look ahead,
look ahead will not actually match any character, so the string pointer is still unchanged.
for example, I want to match a password in following criteria
(1). at least 7 to 8 long
(2). contain at least one special character @#$
(3). contain at least one digit
(?=.*\d)(?=.*[@#$]).{7,8}
(?=.*\d) will peek if there is at least one digit
(?=.*[@#$]) will peek if there is at least one special char
.{7,8} will check the length.
but unfortunately, I found that I can't use reg exp validator provided by VS, it won't work. Unless I put number and special char in the begining, for example: 13@pass, instead of pass@12
However, if I use a custom validator and pasted the same R.E. into the code behind of the server validator, it works perfectly. So I can easily draw a conclusion that R.E. in VS works totally differently in client side (RE validator) and server side (RE class).
is this a bug?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment