- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
Password matching expression. Password must be at least 8 characters, no more than 15 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit.
aaaa1234AAAA | 12aaAA12 | aaaaa12345AAAAA
aaaaa123456AAAAA | 12aaAA1 | 12aaaa12
Author Rating: Not yet rated. Jeff U
Source ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$
Your Rating
Bad Good

Enter New 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: wrong expression
Name: Arun das
Date: 6/14/2015 8:42:00 AM
a 9 A hjkjjk this was matching because of "." used after "?="

Title: fdgfgfd
Name: fdgfdg
Date: 3/4/2015 12:15:22 AM

Title: PPSN
Name: Aaron Rooney
Date: 10/30/2014 6:17:10 PM
im trying to figure out how to use a ppsn number in a regular expression validator i cant figure out the charecters i need to enter please help

Title: PPSN
Name: Aaron Rooney
Date: 10/30/2014 6:12:50 PM
im trying to figure out how to use a ppsn number in a regular expression validator i cant figure out the charecters i need to enter please help

Title: I have require only 6-16 character in string. Can any one have idea for that?
Name: Gaurav Bhandari
Date: 9/13/2012 7:48:19 AM
I have require only 6-16 character in string. Can any one have idea for that?

Title: Note the IE BUG
Name: Microsoft is evil just like Oracle
Date: 7/8/2008 4:24:53 PM
It might be a good idea to move the length check to the beginning and the rest after that, like so: (?=^.{8,15}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*

Title: This expression is NOT broken
Name: Greg C.
Date: 4/10/2008 6:16:23 PM
This isn't broken. It *CAN* validate for at least one upper- and one lower-case letter and one digit. However, the default settings for testing expressions on this site include "Case insensitive". With a case-insensitive match settings, it obviously *will* match "ABSCDEFG1". When testing this, switch OFF the case-insensitive checkbox. And if you want it to work in IE, you need to tweak things like this: ^(?=.{8,15}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).* See

Title: not working as intended
Name: Anon
Date: 10/3/2007 9:20:03 AM
Works for ABCDEFG9 which fails description as at least one lower case is required

Title: possible alternative
Name: Doug
Date: 10/18/2006 5:22:17 PM
I believe this might be a possible alternative: (?=^.{7,12}$)(?=.*\d)(?=.*[A-Z])(?=.*[a-z]).* Since it appears that IE doesn't do the lookaheads properly, I just put the length requirement as the lookahead itself. Notice the ^ and the $ are inside the lookahead that checks the length, otherwise that lookahead would pass on anything greater than or equal to 7 characters. The only other change I make when using this regex myself, is that I prefer to replace the final dot with a character class that has only the characters I prefer to allow: (?=^.{7,12}$)(?=.*\d)(?=.*[A-Z])(?=.*[a-z])[!-~]* or (?=^.{7,12}$)(?=.*\d)(?=.*[A-Z])(?=.*[a-z])[^\s]*

Title: Sorry Not Working
Name: Chandan
Date: 3/8/2005 4:27:34 AM
It is not working with ASP.NET Reg. Exp. Validator. Please if you have any other for the same please mail me in Thank you

Title: problem with lower and upper caps.
Name: Andres Garcia
Date: 10/5/2004 3:27:37 PM
Supposedly 12aaaa12 does not match, but it does. this expression does NOT enforce lower AND upper caps. It enforces alphanumeric and numeric only

Title: Jscript Version Bug
Name: Michael Ash
Date: 10/5/2004 12:33:50 PM
I think I've tracked down the Javascript problem. See

Title: Re: Slight modification for JavaScript
Name: Michael Ash
Date: 10/5/2004 10:44:02 AM
The modified expression is NOT equivalent to the original. In fact the modified version matches everything (except a newline). Try it with 8 of the same character. The movement of the astericks makes all the look-aheads superfluous. Also, there is actually no reason the original shouldn't work in javascript. It is syntaxally sound. There appears to be a bug with the client side engines. I'm getting ood results when testing it.

Title: Slight modification for JavaScript
Name: Dave B.
Date: 10/4/2004 8:47:31 PM
This works great for .NET but not when you try to use .NET RegExp Validators which use client-side JavaScript. I made a small change to work in JavaScript (note the movement of the asterisks): ^(?=.\d*)(?=.[a-z]*)(?=.[A-Z]*).{8,15}$

Title: stink
Name: this sucks and doesnt work
Date: 8/9/2004 12:35:25 PM
it doesnt work in asp

Title: Not universal
Name: Clayton
Date: 7/27/2004 11:35:44 PM
Does not work in IE 6 SP1. Works in Firefox 0.9

Title: JavaScript
Name: Crowcomputer
Date: 5/7/2004 1:58:09 PM
Doesn't work with JavaScript / ASP.NET RegEx Validator controls

Title: Puzzling Error
Name: Sampson
Date: 3/1/2004 11:52:12 AM
When I run this with "test expression" on this site, it works great, but when I try to use it in the built-in reg expression validator on the asp page, it evaluates the expression as requiring 6 numbers, 6 letters. I copied and pasted, so I know the syntax is ok..any thoughts?

Title: Great
Name: Al
Date: 2/25/2004 1:59:51 PM
Great for 8 to 15

Copyright © 2001-2018, | ASP.NET Tutorials