Wednesday, July 07, 2010

Regex for alphanumeric password (at least 1 numeric and 1 alphabet)

Suppose we want to validate for password input, making sure it is of alphanumeric pattern (at least 1 numeric and 1 alphabet) and length of 8 to 10, then we can use the below Regular Expression.
Regex regexObj = new Regex("^(?:(?<ch>[A-Za-z])|(?<num>[9-0])){8,20}$");

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.