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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Valid Usernames
Expression
^([a-zA-Z])[a-zA-Z_-]*[\w_-]*[\S]$|^([a-zA-Z])[0-9_-]*[\S]$|^[a-zA-Z]*[\S]$
Description
Will verify if the text is is in a valid user name format like: is alphanumeric, starts with an alphabet and contains no special characters other than underscore or dash.
Matches
username | user123 |user_123 | user-123 | username123_type
Non-Matches
123username | user name | _username
Author Rating: The rating for this expression. Farhan Sajjad
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: Also Permits Special Characters
Name: Sandeep
Date: 7/5/2012 6:05:54 AM
Comment:
w23-0+


Title: Also permits a single number
Name: Dudlington
Date: 10/9/2009 6:09:00 PM
Comment:
For instance: "1" works, but not "11" or "1a"


Title: Also permits a single number
Name: Dudlington
Date: 10/9/2009 6:05:55 PM
Comment:
For instance: "1" works, but not "11" or "1a"


Title: This permits special characters at the end of the string
Name: Dan Turner
Date: 10/21/2008 4:00:55 PM
Comment:
For instance: asjkASKJJ' passes but asjkA'SKJJ does not


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