Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Regular Expression in password (http://www.velocityreviews.com/forums/t386164-regular-expression-in-password.html)

Chris 02-03-2007 12:45 PM

Regular Expression in password
 
I want to ensure a password has a least one lower case letter, one upper
letter and a number. I'm a bit of a newbie but I understand you can use the
pipe system for OR what about AND.I would like something like this.

[a-z]&[A-Z]&[1-9]



=?Utf-8?B?TWFuaXNoIEJhZm5h?= 02-03-2007 03:36 PM

RE: Regular Expression in password
 
Hi,
Try following expresion:
var regexp = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/
If you find this post useful then please do click yes at "Was this post
helpful to you"

Thanks and Regards,
Manish Bafna.
MCP and MCTS.


"Chris" wrote:

> I want to ensure a password has a least one lower case letter, one upper
> letter and a number. I'm a bit of a newbie but I understand you can use the
> pipe system for OR what about AND.I would like something like this.
>
> [a-z]&[A-Z]&[1-9]
>
>
>


=?ISO-8859-1?Q?G=F6ran_Andersson?= 02-03-2007 03:47 PM

Re: Regular Expression in password
 
Chris wrote:
> I want to ensure a password has a least one lower case letter, one upper
> letter and a number. I'm a bit of a newbie but I understand you can use the
> pipe system for OR what about AND.I would like something like this.
>
> [a-z]&[A-Z]&[1-9]
>
>


There is no and operation in regular expressions. It's not useful, as a
character can not be a lower case letter, an upper case letter and a
digit at the same time. Each character is only one of these.

You can express your demands like any of several different patterns:

something-upper-something-lower-something-digit-something
something-upper-something-digit-something-lower-something
something-lower-something-upper-something-digit-something
something-lower-something-digit-something-upper-something
something-digit-something-upper-something-lower-something
something-digit-something-lower-something-upper-something

The first one would be expressed as:

..*[A-Z].*[a-z].*[1-9].*

Express the others similarly, and put them togther with the or operator:

(.*[A-Z].*[a-z].*[1-9].*)|(...)|(...) ...

--
Göran Andersson
_____
http://www.guffa.com

Riki 02-03-2007 07:27 PM

Re: Regular Expression in password
 
Göran Andersson wrote:
> Chris wrote:
>> I want to ensure a password has a least one lower case letter, one
>> upper letter and a number. I'm a bit of a newbie but I understand
>> you can use the pipe system for OR what about AND.I would like
>> something like this. [a-z]&[A-Z]&[1-9]
>>
>>

>
> There is no and operation in regular expressions.


There is.
See Manish's post.

See also www.regexlib.com and search for "password"

--

Riki



=?ISO-8859-1?Q?G=F6ran_Andersson?= 02-04-2007 12:52 AM

Re: Regular Expression in password
 
Riki wrote:
> Göran Andersson wrote:
>> Chris wrote:
>>> I want to ensure a password has a least one lower case letter, one
>>> upper letter and a number. I'm a bit of a newbie but I understand
>>> you can use the pipe system for OR what about AND.I would like
>>> something like this. [a-z]&[A-Z]&[1-9]
>>>
>>>

>> There is no and operation in regular expressions.

>
> There is.
> See Manish's post.
>
> See also www.regexlib.com and search for "password"
>


That's not an and operation. It's a zero-width positive lookahead.

--
Göran Andersson
_____
http://www.guffa.com


All times are GMT. The time now is 08:31 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.