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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$
Description
I built this expression to test a string in ASP for valid username and password constraints. It can be adapted for any number of scenerios. For instance in this case, we needed to ensure the username someone wanted was not all numbers or all letters and was 6-15 characters in length with no special characters. This expression tests negatively for all number cases, then all letter cases, and lastly tests for only alphanumeric characters in the required range. In other words: the match must be alphanumeric with at least one number, one letter, and be between 6-15 character in length.
Matches
C2dfeed | sporttrak1 | 11223a
Non-Matches
pookie | d34_fff | 123456
Author Rating: The rating for this expression. Pete Lindquist
Source Pete Lindquist
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: PHP BEst
Name: Shashank
Date: 11/21/2017 12:08:01 PM
Comment:
Best Regex For Alphanumeric


Title: Number not mandatory
Name: Lakshmanan
Date: 1/29/2009 11:35:28 PM
Comment:
Number is not mandatory in my case, so how can i use this expression.


Title: Simple and to the Point
Name: Kevin
Date: 6/13/2008 12:25:08 AM
Comment:
This was exactly what I was looking for and is a true definition of begin alphanumeric. It is is either alphabetical, numerical, or alphanumeric. So many examples just didn't see this. I tried to do this on my own and it got really complex and wasn't very flexible. I like your solution better. Thanks for the post.


Title: Simple and to the Point
Name: Kevin
Date: 6/13/2008 12:24:50 AM
Comment:
This was exactly what I was looking for and is a true definition of begin alphanumeric. It is is either alphabetical, numerical, or alphanumeric. So many examples just didn't see this. I tried to do this on my own and it got really complex and wasn't very flexible. I like your solution better. Thanks for the post.


Title: Brillant
Name: Bea
Date: 3/16/2008 7:19:13 PM
Comment:
You actually sort out my problem! thanks mate


Title: Changes
Name: Eli Jurado
Date: 10/13/2006 2:10:33 PM
Comment:
If I need that my string acept at least one non-alphanumeric character, What change I need do?


Title: Good, second Chandan's recommendation
Name: cranbo
Date: 6/16/2005 7:38:44 PM
Comment:
Would love to see this so it requires 3 of 4: one lower, one upper, one number, one non-word (special char) In any case, thanks for the ideas!


Title: Good
Name: Chandan
Date: 3/8/2005 4:42:47 AM
Comment:
Good for One Numeric & One Alpha. but Can You provide at least one numeric, ome lower alpha., one upper aplha. with range.


Title: Thanks
Name: Pete
Date: 10/27/2004 10:44:32 AM
Comment:
Thanks for the addition. Looks to do a good job beefing it up.


Title: Addition
Name: Cstick
Date: 10/25/2004 10:39:45 AM
Comment:
(?!^[0-9]*$)(?!^[a-zA-Z_@]*$)(?!^[0-9_@]{1})^([a-zA-Z0-9_@]{6,16})$ I added to yours so that it tests that string is not all "_" or "@", does not start with 0-9, "_", or "@", must start with a letter and must include at least one number, string must be between 6-16 characters long. Your expression was the easiest for me to build on. Thx.


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