Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Checking password input with regular expression

Reply
Thread Tools

Checking password input with regular expression

 
 
JJ
Guest
Posts: n/a
 
      09-18-2006
To validate a password as the user is registering I want to use a regular
expressio validator.

I got this one from the Microsoft web site for validating a password of at
least 7 characters, with at least one number and one non-alphanumeric
character:

@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})

Yet I can't get it to validate that a password like qwertyui123# fits the
criteria.

Or any password for that matter. Can anyone help with a regular expression
that works? or am I goong wrong somewhere?

JJ


 
Reply With Quote
 
 
 
 
Markus Palme
Guest
Posts: n/a
 
      09-18-2006
> I got this one from the Microsoft web site for validating a password of at
> least 7 characters, with at least one number and one non-alphanumeric
> character:
>
> @\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})
>
> Yet I can't get it to validate that a password like qwertyui123# fits the
> criteria.


@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})

This one works, just a typing mistake.

Markus

 
Reply With Quote
 
 
 
 
ThunderMusic
Guest
Posts: n/a
 
      09-19-2006
it does not work for me... is there something I should know? I tested it
on this site : http://regexlib.com/RETester.aspx?regexp_id=887 and it never
matches.

thanks

ThunderMusic

"Markus Palme" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed) om...
>> I got this one from the Microsoft web site for validating a password of
>> at
>> least 7 characters, with at least one number and one non-alphanumeric
>> character:
>>
>> @\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})
>>
>> Yet I can't get it to validate that a password like qwertyui123# fits
>> the
>> criteria.

>
> @\"(?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})
>
> This one works, just a typing mistake.
>
> Markus
>



 
Reply With Quote
 
JJ
Guest
Posts: n/a
 
      09-19-2006
Markus,

Surely by changing the 'W' to 'w' you are not looking for patterns with
non-alphanumeric characters in it?

the (?=*\W){1}) means the pattern must have one or more non-alphanumeric
characters in it.

I think the problem lies with the initial @\" . Clearly the expression is
trying to match a pattern that does not have a '@' or a ' " ' in it, but if
you remove this part of the expression, it works as expected, allbeit
allowing those 2 'disallowed' characters.

Anyone work out what the correct notation should be?

JJ

"Markus Palme" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>> I got this one from the Microsoft web site for validating a password of
>> at
>> least 7 characters, with at least one number and one non-alphanumeric
>> character:
>>
>> @\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})
>>
>> Yet I can't get it to validate that a password like qwertyui123# fits
>> the
>> criteria.

>
> @\"(?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})
>
> This one works, just a typing mistake.
>
> Markus
>



 
Reply With Quote
 
Markus Palme
Guest
Posts: n/a
 
      09-19-2006

JJ schrieb:

> Markus,
>
> Surely by changing the 'W' to 'w' you are not looking for patterns with
> non-alphanumeric characters in it?


My mistake, sorry - I missed the "non-"alphanumeric. The regex of
course, is only this part:

(?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})

Markus

 
Reply With Quote
 
JJ
Guest
Posts: n/a
 
      09-19-2006
Sorry Markus I still can't see that it makes sense to me.

If I am searching for a pattern that matches 7 or more characters containing
1 or more digits and 1 or more non-alphanumeric characters,
I can't see how this would work.

I understand I may be going wrong somewhere, but where?

The original @\" at the beginning was meant to make sure that those
characters are not part of the password. So, as far as I can see they do
need to be part of the regular expression.

JJ



"Markus Palme" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>
> JJ schrieb:
>
>> Markus,
>>
>> Surely by changing the 'W' to 'w' you are not looking for patterns with
>> non-alphanumeric characters in it?

>
> My mistake, sorry - I missed the "non-"alphanumeric. The regex of
> course, is only this part:
>
> (?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})
>
> Markus
>



 
Reply With Quote
 
JJ
Guest
Posts: n/a
 
      09-19-2006
How about this one:

^.*(?=.{7,})(?=.*\d)(?=.*[a-zA-Z])(?=.*[@#$%^&+=]).*$

That breaks down as:

7 characters;
must contain a digit;
must contain a character in the range a-z or A-Z;
must contain one of these characters @#$%^&+=

I've run some quick tests and its seems to work for me, but be grateful for
anyone elses views?

JJ




"JJ" <(E-Mail Removed)> wrote in message
news:ua%(E-Mail Removed)...
> Sorry Markus I still can't see that it makes sense to me.
>
> If I am searching for a pattern that matches 7 or more characters
> containing 1 or more digits and 1 or more non-alphanumeric characters,
> I can't see how this would work.
>
> I understand I may be going wrong somewhere, but where?
>
> The original @\" at the beginning was meant to make sure that those
> characters are not part of the password. So, as far as I can see they do
> need to be part of the regular expression.
>
> JJ
>
>
>
> "Markus Palme" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>>
>> JJ schrieb:
>>
>>> Markus,
>>>
>>> Surely by changing the 'W' to 'w' you are not looking for patterns with
>>> non-alphanumeric characters in it?

>>
>> My mistake, sorry - I missed the "non-"alphanumeric. The regex of
>> course, is only this part:
>>
>> (?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})
>>
>> Markus
>>

>
>



 
Reply With Quote
 
ThunderMusic
Guest
Posts: n/a
 
      09-19-2006
ok, so Here it is, the supreme regex for passwords...

^.*(?=.{7,})((?=.*\d)(?=.*[a-z])(?=.*[A-Z])|(?=.*\d)(?=.*[a-z])(?=.*[^a-zA-Z0-9])|(?=.*\d)(?=.*[A-Z])(?=.*[^a-zA-Z0-9])|(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])).*$

it tests for 3 of these 4 cases : 1 a-z, 1 A-Z, 1 digit, 1 non-alphanumeric.
7 chars minimum... you can test it, it works fine... I'll add it to my
validations.

I hope helps

ThunderMusic


"JJ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How about this one:
>
> ^.*(?=.{7,})(?=.*\d)(?=.*[a-zA-Z])(?=.*[@#$%^&+=]).*$
>
> That breaks down as:
>
> 7 characters;
> must contain a digit;
> must contain a character in the range a-z or A-Z;
> must contain one of these characters @#$%^&+=
>
> I've run some quick tests and its seems to work for me, but be grateful
> for anyone elses views?
>
> JJ
>
>
>
>
> "JJ" <(E-Mail Removed)> wrote in message
> news:ua%(E-Mail Removed)...
>> Sorry Markus I still can't see that it makes sense to me.
>>
>> If I am searching for a pattern that matches 7 or more characters
>> containing 1 or more digits and 1 or more non-alphanumeric characters,
>> I can't see how this would work.
>>
>> I understand I may be going wrong somewhere, but where?
>>
>> The original @\" at the beginning was meant to make sure that those
>> characters are not part of the password. So, as far as I can see they do
>> need to be part of the regular expression.
>>
>> JJ
>>
>>
>>
>> "Markus Palme" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) oups.com...
>>>
>>> JJ schrieb:
>>>
>>>> Markus,
>>>>
>>>> Surely by changing the 'W' to 'w' you are not looking for patterns with
>>>> non-alphanumeric characters in it?
>>>
>>> My mistake, sorry - I missed the "non-"alphanumeric. The regex of
>>> course, is only this part:
>>>
>>> (?=.{7,})(?=(.*\d){1,})(?=(.*\w){1,})
>>>
>>> Markus
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
Checking that user has entered a word or words in text input form using regular expressions... Luke Matuszewski Javascript 8 04-22-2006 07:47 AM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments