asp.net - Combining 2 regular expression in web.config passwordStrengthRegularExpression="" -


i not able combine below 2 regular expressions. password standard requirement:

  • password cannot contain username or parts of full name exceeding 2 consecutive characters
  • passwords must @ least 6 characters in length
  • passwords must contain characters 3 of following categories
    • uppercase characters (english a-z)
    • lowercase characters (english a-z)
    • base 10 digits (0-9)
    • non-alphabetic characters (e.g., !, @, #, $, %, etc.)

expression:

passwordstrengthregularexpression="((?=.*\d)(?=.*[a-z])(?=.*[a-z])(?=.*[@#$%]).{6,20})" 

passwords cannot contain word “test” or “test” or variants of word

passwordstrengthregularexpression="((?=.*\"^((?!test|test|test).*)$" 

both working fine individually.

because second regexp uses negative lookahead, can remodel , stick right @ beginning of other expression. first, i'm going change second regex to:

"(?!.*(?:test|test|test))" 

in english, string may not contain number of (or zero) characters followed test.

then, i'm going stick right @ beginning of other expression

passwordstrengthregularexpression="^(?!.*(?:test|test|test))(?=.*\d)(?=.*[a-z])(?=.*[a-z])(?=.*[@#$%]).{6,20}$" 

finally, i'm going show how make 1 part of regex case-insensitive. may or may not supported depending on program for.

passwordstrengthregularexpression="^(?!.*(?i:test))(?=.*\d)(?=.*[a-z])(?=.*[a-z])(?=.*[@#$%]).{6,20}$" 

see (?i:...)? means flags between ? , : applied part of expression, is, area case-insensitive.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -