RegularExpression Validation for password in ASP.NET

RegularExpression Validation for password in ASP.NET

am 10.04.2008 21:24:59 von bienwell

Hi all,

Can any one help me to write a regular expression to validate the password
entered on the text field in ASP.NET. The rules for the password are:
1- There must be at least one number in the password.
2- There must be upper and lower case letters in the password.
3- Password must begin with an alphabetic character.
4- Password cannot contain illegal characters, such as =, <, >, ;, :, '
, " or comma (equal sign, greater sign, less than sign, semicolon, colon,
single quote, double quotes, comma).
5- Password must be between 8 and 25 characters.

I'm not good at writing the expression. Please help me out.

Thanks in advance.

Re: RegularExpression Validation for password in ASP.NET

am 11.04.2008 00:19:45 von sanjay.uttam

On Apr 10, 3:24 pm, "bienwell" wrote:
> Hi all,
>
> Can any one help me to write a regular expression to validate the password
> entered on the text field in ASP.NET. The rules for the password are:
> 1- There must be at least one number in the password.
> 2- There must be upper and lower case letters in the password.
> 3- Password must begin with an alphabetic character.
> 4- Password cannot contain illegal characters, such as =, <, >, ;, :, '
> , " or comma (equal sign, greater sign, less than sign, semicolon, colon,
> single quote, double quotes, comma).
> 5- Password must be between 8 and 25 characters.
>
> I'm not good at writing the expression. Please help me out.
>
> Thanks in advance.

RegularExpressions.Regex.IsMatch(lblYourPw, "(?!^[0-9]*$)(?!^[a-zA-Z]*
$)^([a-zA-Z0-9]{8,10})$"))

"Validates a strong password. It must be between 8 and 10 characters,
contain at least one digit and one alphabetic character, and must not
contain special characters" I think you're 90% of the way there (got
it from http://msdn2.microsoft.com/en-us/library/ms998267.aspx)

Re: RegularExpression Validation for password in ASP.NET

am 11.04.2008 10:52:18 von wisccal

I'm not a regex expert either, but based on the previous post, this
seems to work:

Regex.IsMatch(
input, "(?!^[0-9]*$)(?!^[a-z]*$)(?!^[A-Z]*$)(?!^[a-z0-9]*$)(?!^[A-
Z0-9]*$)^([a-zA-Z][a-zA-Z0-9]{8,25})$")
)

============
Regards,
Steve
www.stkomp.com

bienwell wrote:
> Hi all,
>
> Can any one help me to write a regular expression to validate the password
> entered on the text field in ASP.NET. The rules for the password are:
> 1- There must be at least one number in the password.
> 2- There must be upper and lower case letters in the password.
> 3- Password must begin with an alphabetic character.
> 4- Password cannot contain illegal characters, such as =, <, >, ;, :, '
> , " or comma (equal sign, greater sign, less than sign, semicolon, colon,
> single quote, double quotes, comma).
> 5- Password must be between 8 and 25 characters.
>
> I'm not good at writing the expression. Please help me out.
>
> Thanks in advance.

Re: RegularExpression Validation for password in ASP.NET

am 15.04.2008 14:50:05 von bienwell

Thanks fyi.

"RhythmAddict" wrote in message
news:61ef59f1-90bb-45a3-a5db-2d100a903662@59g2000hsb.googleg roups.com...
> On Apr 10, 3:24 pm, "bienwell" wrote:
>> Hi all,
>>
>> Can any one help me to write a regular expression to validate the
>> password
>> entered on the text field in ASP.NET. The rules for the password are:
>> 1- There must be at least one number in the password.
>> 2- There must be upper and lower case letters in the password.
>> 3- Password must begin with an alphabetic character.
>> 4- Password cannot contain illegal characters, such as =, <, >, ;, :,
>> '
>> , " or comma (equal sign, greater sign, less than sign, semicolon, colon,
>> single quote, double quotes, comma).
>> 5- Password must be between 8 and 25 characters.
>>
>> I'm not good at writing the expression. Please help me out.
>>
>> Thanks in advance.
>
> RegularExpressions.Regex.IsMatch(lblYourPw, "(?!^[0-9]*$)(?!^[a-zA-Z]*
> $)^([a-zA-Z0-9]{8,10})$"))
>
> "Validates a strong password. It must be between 8 and 10 characters,
> contain at least one digit and one alphabetic character, and must not
> contain special characters" I think you're 90% of the way there (got
> it from http://msdn2.microsoft.com/en-us/library/ms998267.aspx)

Re: RegularExpression Validation for password in ASP.NET

am 15.04.2008 14:50:28 von bienwell

Thanks for your help.

wrote in message
news:60d1bad3-1e68-4a1f-bf2a-fd7b53153cd2@b64g2000hsa.google groups.com...
> I'm not a regex expert either, but based on the previous post, this
> seems to work:
>
> Regex.IsMatch(
> input, "(?!^[0-9]*$)(?!^[a-z]*$)(?!^[A-Z]*$)(?!^[a-z0-9]*$)(?!^[A-
> Z0-9]*$)^([a-zA-Z][a-zA-Z0-9]{8,25})$")
> )
>
> ============
> Regards,
> Steve
> www.stkomp.com
>
> bienwell wrote:
>> Hi all,
>>
>> Can any one help me to write a regular expression to validate the
>> password
>> entered on the text field in ASP.NET. The rules for the password are:
>> 1- There must be at least one number in the password.
>> 2- There must be upper and lower case letters in the password.
>> 3- Password must begin with an alphabetic character.
>> 4- Password cannot contain illegal characters, such as =, <, >, ;, :,
>> '
>> , " or comma (equal sign, greater sign, less than sign, semicolon, colon,
>> single quote, double quotes, comma).
>> 5- Password must be between 8 and 25 characters.
>>
>> I'm not good at writing the expression. Please help me out.
>>
>> Thanks in advance.