Search code examples
asp.netregexpasswordscreateuserwizard

ASP.NET default regular expression for users' passwords


What is the default regular expression used by asp.net create user wizard?

According to the MSDN documentation, it should be something like this:

Regular Expression: @\"(?:.{7,})(?=(.*\d){1,})(?=(.*\W){1,})

Validation Message: Your password must be 7 characters long, and contain at least one number and one special character.

However, it does not work as it does not accept something like 3edc£edc, which is actually accepted when using the default create user wizard.

Any idea about how can I get this regular expression?


Solution

  • Just change the order

    ^(?=(.*\d))(?=(.*\W)).{7,}
    

    I additionally removed the {1,} and anchored it to the start of the string and you don't need a group around the last part

    See it here on Regexr