Navaz Baig
Navaz Baig

Reputation: 73

Regex for "password must contain at least one non-alphanumeric character"

I am looking to use regex pattern to replace membership method MembershipCreateStatus.InvalidPassword for Password validation. Criteria for valid password is "A valid password must contain at least one non-alphanumeric character. (test.123 is an example of a valid password)". I have used following regex pattern, but it does not seem to match criteria.

/^(?=.*(\W)).{5,20}$/

Upvotes: 0

Views: 3958

Answers (1)

Bart K
Bart K

Reputation: 324

/([^a-zA-Z\d])+([a-zA-Z\d])+|([a-zA-Z\d])+([^a-zA-Z\d])+/

Upvotes: 3

Related Questions