• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 647
  • Last Modified:

Regex Password Validation

Can someone provide me with a regex string that I can use in C# for password validation?  The requirements are as follows:

Character length: 7-30.
Must contain at least one number.
Must contain at least one symbol/special character.
Remaining characters can contain any combination of upper/lower case letters, numbers and symbols.

Thanks!
0
mdtanner
Asked:
mdtanner
1 Solution
 
maheshsnkrCommented:
hi  
mdtanner,

Try the following regex

^.*(?=.{7,})(?=.*[0-9])(?=.*[@#$%^&+=]).*$

This will check the follwoing conditions

Character length: 7 (won't check the max length as 30 - put the maxlength of the textbox to 30)
Must contain at least one number.
Must contain at least one symbol/special character- (])(?=.*[@#$%^&+=] are the included special characters)

0
 
Obadiah ChristopherCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now