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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(?=[^\d_].*?\d)\w(\w|[!@#$%]){7,20}
Description
This regex can be used to restrict passwords to a length of 8 to 20 aplhanumeric characters and select special characters. The password also can not start with a digit, underscore or special character and must contain at least one digit.
Matches
password1 | pa$$word2 | pa!@#$%3
Non-Matches
password | 1stpassword | $password#
Author Rating: The rating for this expression. Michael Ash
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: $?
Name: Christina
Date: 2/8/2013 10:15:28 AM
Comment:
Does there need to be a $ at the end of this RegEx?


Title: Password style
Name: Raghavendra
Date: 5/31/2010 11:55:28 AM
Comment:
HI, I want to restrict user to not to user the special charcters {',;,*} how can i attain this Thanks in ADV Raghavendra


Title: <iframe ID="hisad" runat="server" ></iframe>
Name: dfxg
Date: 1/22/2009 9:16:20 AM
Comment:
dsf


Title: Well Done
Name: Mansnour
Date: 8/20/2007 5:32:01 AM
Comment:
Hi How can i make start with a digit but not with a special character Thanks in advanced


Title: Works Great
Name: Denise
Date: 1/19/2007 12:56:41 AM
Comment:
Finally, something that worked like I wanted. Changed my length requirements and took out special characters. Only think I can't find is what the \w actually includes besides letters, numbers, and the underscore. I want to make sure input does not include html tags.


Title: Re: Problem
Name: Michael Ash
Date: 4/19/2005 12:36:00 PM
Comment:
Aditya this already limits the number of characters it accepts so I'm not sure what you are asking. To allow spaces simple add a space between the square brackets.


Title: Problem
Name: Aditya
Date: 4/14/2005 1:19:39 PM
Comment:
how to use this to restrict the no of charactes in a string also it shd accept spaces.


Title: Thumbs up
Name: Michael
Date: 6/3/2004 2:02:47 PM
Comment:
Right on. This works great. It did not take much to allow spaces


Title: re: problem
Name: Michael Ash
Date: 2/27/2004 7:15:07 PM
Comment:
I'm afraid I don't understand what you are asking.


Title: problem
Name: nader ashfaq
Date: 2/27/2004 8:38:20 AM
Comment:
its a very good site and like it very much i want some help from you about my prob i am a student of "dwd"in pakistan and i am so tired about "sql"server maintaining what i can do for this problem.


Title: With mods can be used for variable names
Name: Michael Ash
Date: 2/11/2004 2:11:40 AM
Comment:
With a few slight modification this could also be used to check valid variable names of programming languages. Most languages I know follow similar restictions to variable names. Remove the requirement of a digit (.*?\d) and change the lengh restictions and the list of special characters to whatever is approiate to the language in question.


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