Possible Duplicate:
RegEx to make sure that the string contains at least one lower case char, upper case char, digit and symbol
What would be th开发者_JS百科e regex to make sure that a given string contains at least one character from each of the followings ---
- upper case letter
- lower case letter
- no whitespace
- digit
- symbol
- string length is >=5 and <=10
how to combine all these above criteria to validate a string.
If it has to be a regex:
^ # Start of string
(?=.*[A-Z]) # upper case (ASCII) letter
(?=.*[a-z]) # lower case letter
(?=.*\d) # digit
(?=.*[\W_]) # symbol
\S # no whitespace
{5,10} # string length is >=5 and <=10
$ # end of string
or, if your regex flavor doesn't support verbose regexes:
^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_])\S{5,10}$
精彩评论