473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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]
Feb 3 '07 #1
4 4719
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]
Feb 3 '07 #2
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
Feb 3 '07 #3
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
Feb 3 '07 #4
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
Feb 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ron Adam | last post by:
Is it possible to match a string to regular expression pattern instead of the other way around? For example, instead of finding a match within a string, I want to find out, (pass or fail), if...
4
by: Steve | last post by:
Hi all I have to validate a password to determine whether or not it adheres to certain rules. For example, the password must contain at least 1 number, at least 1 uppercase character and at...
5
by: Henry | last post by:
I have this simple code, string escaped = Regex.Escape( @"`~!@#$%^&*()_=+{}\|;:',<.>/?" + "\"" ); string input = @"a&+" + "\"" + @"@(-d)\e"; Regex re = new Regex( string.Format(@"(+)", escaped),...
9
by: Stirling | last post by:
Hi all, hope someone can help me, I am looking to do a password validation check using client side validation. Minimum requirement is that it must contain at least one number and one letter. ...
3
by: Ryan Taylor | last post by:
Hello. I am trying to create a regular expression that will let me know if a string has the following criteria. Order does not matter in the string, but when building a regular expression it...
2
by: Peter Rietmann | last post by:
I have the problem to validate a password with a length of at least 6 and maximum 15 and the condition that it contains at least 2 numbers ie. (1aaaa1, aaaa11, 11aaaa). I am using the microsoft...
6
by: vvenk | last post by:
Hello: I am trying to learn about regular expressions. How would I use regular expressions to ensure that the password an user enters conforms to the following rules: 1. It has to be...
7
by: JJ | last post by:
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...
18
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
by: AAaron123 | last post by:
Been playing with asp:changepassword and have it looking OK except that I can't elininate or change the title at the top that says "Change Your Password". It's a repeat of my pages title. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.