473,403 Members | 2,270 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,403 software developers and data experts.

Password Regular Espression

Bob Ross
119 100+
I am trying to validate a password field with regular expression.
the trouble is none of the ones I find on the net seem to work.
Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ 
This won't allow Hello12 which it should

Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$
This won't allow Hello12 either.

Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$
This won't allow Hello12*

Basically every RegEx I look up won't work as intended. And I have no idea why.
Nothing seems to pass the validation at all.
All I am using is a textbox and regular expression validator.

Can anyone help me?
Aug 31 '07 #1
10 1899
Kermit
16
I am trying to validate a password field with regular expression.
the trouble is none of the ones I find on the net seem to work.
Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ 
This won't allow Hello12 which it should

Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$
This won't allow Hello12 either.

Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$
This won't allow Hello12*

Basically every RegEx I look up won't work as intended. And I have no idea why.
Nothing seems to pass the validation at all.
All I am using is a textbox and regular expression validator.

Can anyone help me?
I may be wrong, as I don't get the notation, but the first code does not allow digits. Try
Expand|Select|Wrap|Line Numbers
  1. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{4,8}$ 
Aug 31 '07 #2
Bob Ross
119 100+
\d is short hand for [0-9] in RegEx's.
But I have also tried your way to no avail.

It seems to only allow the charactors in order.
For example 12Hello but not Hello12.
Aug 31 '07 #3
Kermit
16
\d is short hand for [0-9] in RegEx's.
But I have also tried your way to no avail.
Ok, but this ^ in front of \d means that you don't accept digits, right?
Aug 31 '07 #4
Bob Ross
119 100+
According to
http://www.regular-expressions.info/anchors.html
It is something to do with the start of a new line in this context.
Can't say I really understand RegExs myself.

But I have tried without ^ and $ but seems to make no difference.
Aug 31 '07 #5
dotneto
36
According to
http://www.regular-expressions.info/anchors.html
It is something to do with the start of a new line in this context.
Can't say I really understand RegExs myself.

But I have tried without ^ and $ but seems to make no difference.

yes, ^ and $ mark the beggining and end, ^ is only negation when you use it insede square brackets.
Maybe you can explain us your password policy and we can help you built your regex?
Aug 31 '07 #6
dotneto
36
yes, ^ and $ mark the beggining and end, ^ is only negation when you use it insede square brackets.
Maybe you can explain us your password policy and we can help you built your regex?

I don't get what are you tring to do with your regex, but it seems like too compicated.
Look, at the first part, ^($=.*\n), this expression will match the start of the line only, since you are using ($=, this is a regex token to look for a char with some other ahead of it.

in example, a($=b), will look for an a followed by a b, like ab, but will only match the a. So ^($=.*\n) will match if there is any character or none (the .*) followed by a digit after the beggining of the word. i Don't think is necessary to use the lookahead token. Tell us what you want to match and maybe we can help you.

Bye.
Aug 31 '07 #7
Bob Ross
119 100+
Okay thanks very much.
I want a RexExp to make sure my password is
  • 6-20 characters long
  • at least one alpha and one numeric
  • maybe one upper and one lower cases latter (at least) but I'm not desperatre for this

Been trying to use the expression on regexlib.com but none of them seem to work.

Thanks in advance
Sep 4 '07 #8
Bob Ross
119 100+
I know it is a lto to ask but I could also do with a username RegExp.
Something that only allows 4-20 characters that re numbers, letters or _.
Would be good if any one can help.
Sep 4 '07 #9
nateraaaa
663 Expert 512MB
Okay thanks very much.
I want a RexExp to make sure my password is
  • 6-20 characters long
  • at least one alpha and one numeric
  • maybe one upper and one lower cases latter (at least) but I'm not desperatre for this

Been trying to use the expression on regexlib.com but none of them seem to work.

Thanks in advance
Go to Regular Expression Library site and enter passwords in the keywords textbox. There is a RegEx there by Michael Ash that should be what you want. If not you can configure it a bit more.

Nathan
Sep 4 '07 #10
Bob Ross
119 100+
Go to Regular Expression Library site and enter passwords in the keywords textbox. There is a RegEx there by Michael Ash that should be what you want. If not you can configure it a bit more.

Nathan
Except that it does not work.
Try it on
http://www.quanetic.com/regex.php
or any other regex tester online.

I think I may use the AJAX password strength control now.
But would rather not.
Also still need reg ex for username.
Sep 4 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: James | last post by:
We have our own set of users and passwords for our application and we want to implement strong passwords. My question is can you access the windows password policy settings in order to validate a...
4
by: Alvaro G. Vicario | last post by:
I’m writing a web application that needs to keep passwords in a database. These passwords are for third-party services and are different from the regular login passwords. I don’t like...
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...
1
by: hurshprasad | last post by:
When using DAO user newpassword function how do you get old password with out prompting the user? Or how can you retreive it without prompting user? user.NewPassword oldPWD, newPWD
0
by: =?Utf-8?B?am1obWFpbmU=?= | last post by:
I'm trying to create a process that allows me to limit the non-alphanumeric characters generated with the PasswordRecovery control. Specially I want to suppress some characters for security...
4
by: Jon Paal | last post by:
when user loses their password, the membership module emails a new password , the format is very complex. how can I set the format to be simple alphanumeric - say 7 characters long ?
4
by: Chris | last post by:
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...
2
by: Pakku | last post by:
Hi, Wondering if someone could point me to a piece of code that checks to see if password being created is at least 8 char long and has a number and a special character... Thanks
3
by: Nathan Sokalski | last post by:
I have an UpdatePanel that needs to maintain the value of several TextBoxes with TextMode=Password. Since the browser clears all password fields client-side, I obviously need to use JavaScript to...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.