RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Strong Password
Expression
^(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{7,30}$
Description
The basic expression requires at least 1 lower case, 1 upper case, 1 numeric, 1 non-word and no whitespace. <br /><br /> The format of the expression lends itself to being parameterised, thus in C# I have a method that returns a modified pattern based on passed in parameters e.g. <br /><br />return "^(?=(.*[a-z]){" + minLowerCase.ToString() + ",})"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ "(?=(.*[\d]){" + minNumeric.ToString() + ",})"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ ".{" + minLength.ToString() + "," + maxLength.ToString() + "}$");<br /><br />Its then possible to set the password strength via configuration files which require strong passwords in production environments, but allow weaker passwords in development environments.
Matches
qW1@xxx
Non-Matches
qwerty123
Author Rating: Not yet rated. Chris Stead
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Just what I needed
Name: no roxa áj
Date: 9/25/2019 10:09:35 AM
Comment:
I'm so happy I've been searching for 40 minutes for a meaningful password regex. Thank you!


Title: Just what I needed
Name: no roxa áj
Date: 9/25/2019 10:09:18 AM
Comment:
I'm so happy I've been searching for 40 minutes for a meaningful password regex. Thank you!


Title: Just what I needed
Name: no roxa áj
Date: 9/25/2019 10:08:21 AM
Comment:
I'm so happy I've been searching for 40 minutes for a meaningful password regex. Thank you!


Title: Missing upper case not anymore
Name: Sub
Date: 10/7/2013 5:23:32 PM
Comment:
yeah ken nailed it try this ^(?=(.*[A-Z]){1,})(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{6,30}$^


Title: Missing upper case not anymore
Name: Sub
Date: 10/7/2013 5:23:13 PM
Comment:
yeah ken nailed it try this ^(?=(.*[A-Z]){1,})(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{6,30}$^


Title: Missing upper case not anymore
Name: Sub
Date: 10/7/2013 5:22:55 PM
Comment:
yeah ken nailed it try this ^(?=(.*[A-Z]){1,})(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{6,30}$^


Title: Missing uppper case
Name: Amit
Date: 4/4/2009 2:15:11 AM
Comment:
Passes following password: @#$34eer


Title: does not work in javascript
Name: does not work in javascript
Date: 3/21/2008 4:31:28 PM
Comment:
does not work in javascript


Title: Missing uppercase requirement??
Name: Ken
Date: 4/18/2007 6:32:35 PM
Comment:
This is just what I was looking for. But I think you need to add this to the regex: (?=(.*[A-Z]){1,})


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials