473,722 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Password Regular Espression

Bob Ross
119 New Member
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 1923
Kermit
16 New Member
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 New Member
\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 New Member
\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 New Member
According to
http://www.regular-expressions.inf o/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 New Member
According to
http://www.regular-expressions.inf o/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 New Member
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 New Member
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 New Member
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 Recognized Expert Contributor
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

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

Similar topics

2
2839
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 password the user has typed in? Even if you cant use the password history for your own passwords, it would still be useful to use the other settings like minimum length etc... We could store our own format for the password maybe as a regular...
4
4160
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 storing this sensitive info as plain text and one-way hashing is not an option because I need the actual passwords. I’ve done some quick research and it seems that symmetric encryption algorithms (blowfish, AES…) provide a reasonable solution—I...
7
2716
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 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
1
1593
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
2023
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 reasons. With textboxes I'm doing this with a RegularExpressionValidator control and have the following the following attribute setup: ValidationExpression="^{6,100}" This limits the user input to alphanumeric characters as well of some selected...
4
3265
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
4732
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 something like this. &&
2
1446
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
2992
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 do this. Can someone help me? Thanks. Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
8863
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.