-1

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?

xanatos
  • 109,618
  • 12
  • 197
  • 280
aleafonso
  • 2,244
  • 8
  • 38
  • 58
  • you can search a regular expression according to your requirement on this URL : http://regexlib.com/Search.aspx?k=password – Gaurav Agrawal Mar 13 '12 at 09:56
  • @GauravAgrawal although I appreciate your answer, it is not what I am looking for. My question was very specific: "What is the default regular expression used by asp.net create user wizard?". As you can see, there is no way I can find that out through the link that you provided. Regards, – aleafonso Mar 13 '12 at 11:11

2 Answers2

1

The error is in the ?: in (?:.{7,})(?=(.*\d){1,})(?=(.*\W){1,}) that is "consuming" the fist seven characters or more characters. It should be ?= OR you can invert the order: (?=(.*\d){1,})(?=(.*\W){1,})(?:.{7,})

xanatos
  • 109,618
  • 12
  • 197
  • 280
0

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

stema
  • 90,351
  • 20
  • 107
  • 135