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

Please support RegExLib Sponsors

Sponsors

Expressions by User

Change page:   |    Displaying page 1 of 3 pages; Items 1 to 20
Title Test Details One Numeric Digit
Expression
^\d$
Description
Matches exactly 1 numeric digit (0-9).
Matches
1 | 2 | 3
Non-Matches
a | 324 | num
Author Rating: The rating for this expression. Steven Smith
Title Test Details Five Integer US ZIP Code
Expression
^\d{5}$
Description
Matches 5 numeric digits, such as a zip code.
Matches
33333 | 55555 | 23445
Non-Matches
abcd | 1324 | as;lkjdf
Author Rating: The rating for this expression. Steven Smith
Title Test Details ZIP+4 - XXXXX-XXXX
Expression
^\d{5}-\d{4}$
Description
Numeric and hyphen 5+4 ZIP code match for ZIP+4.
Matches
22222-3333 | 34545-2367 | 56334-2343
Non-Matches
123456789 | A3B 4C5 | 55335
Author Rating: The rating for this expression. Steven Smith
Title Test Details US ZIP (5 or 5+4)
Expression
^\d{5}$|^\d{5}-\d{4}$
Description
This regular expression will match either a 5 digit ZIP code or a ZIP+4 code formatted as 5 digits, a hyphen, and another 4 digits. Other than that, this is just a really really long description of a regular expression that I'm using to test how my front page will look in the case where very long expression descriptions are used.
Matches
55555-5555 | 34564-3342 | 90210
Non-Matches
434454444 | 645-32-2345 | abc
Author Rating: Not yet rated. Steven Smith
Title Test Details Any One US ASCII Letter
Expression
^[a-zA-Z]$
Description
Matches any single upper- or lower-case letter.
Matches
a | B | c
Non-Matches
0 | & | AbC
Author Rating: Not yet rated. Steven Smith
Title Test Details A string of any US ASCII letters
Expression
^[a-zA-Z]+$
Description
Matches any string of only upper- and lower- case letters (no spaces).
Matches
abc | ABC | aBcDeF
Non-Matches
abc123 | mr. | a word
Author Rating: Not yet rated. Steven Smith
Title Test Details Alphanumeric
Expression
^[a-zA-Z0-9]+$
Description
Matches any alphanumeric string (no spaces).
Matches
10a | ABC | A3fg
Non-Matches
45.3 | this or that | $23
Author Rating: Not yet rated. Steven Smith
Title Test Details Positive Integer
Expression
^\d+$
Description
Positive integer value.
Matches
123 | 10 | 54
Non-Matches
-54 | 54.234 | abc
Author Rating: The rating for this expression. Steven Smith
Title Test Details Signed Integer
Expression
^(\+|-)?\d+$
Description
Matches any signed integer.
Matches
-34 | 34 | +5
Non-Matches
abc | 3.1415 | -5.3
Author Rating: Not yet rated. Steven Smith
Title Test Details Strongish Password
Expression
^[a-zA-Z]\w{3,14}$
Description
The password's first character must be a letter, it must contain at least 4 characters and no more than 15 characters and no characters other than letters, numbers and the underscore may be used
Matches
abcd | aBc45DSD_sdf | password
Non-Matches
afv | 1234 | reallylongpassword
Author Rating: Not yet rated. Steven Smith
Title Test Details Email - Overly Simple
Expression
^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$
Description
Simple email expression. Doesn't allow numbers in the domain name and doesn't allow for top level domains that are less than 2 or more than 3 letters (which is fine until they allow more). Doesn't handle multiple "." in the domain (joe@abc.co.uk).
Matches
joe@aol.com | ssmith@aspalliance.com | a@b.cc
Non-Matches
joe@123aspx.com | joe@web.info | joe@company.co.uk
Author Rating: The rating for this expression. Steven Smith
Title Test Details Date With Slashes
Expression
^\d{1,2}\/\d{1,2}\/\d{4}$
Description
This regular expressions matches dates of the form XX/XX/YYYY where XX can be 1 or 2 digits long and YYYY is always 4 digits long.
Matches
4/1/2001 | 12/12/2001 | 55/5/3434
Non-Matches
1/1/01 | 12 Jan 01 | 1-1-2001
Author Rating: The rating for this expression. Steven Smith
Title Test Details Pattern Title
Expression
foo
Description
The "hello world" of regular expressions, this will match any string with an instance of 'foo' in it.
Matches
foo
Non-Matches
bar
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[1-5]$
Description
This matches a single numeric digit between 1 and 5, and is the same as saying ^[12345]$.
Matches
1 | 3 | 4
Non-Matches
6 | 23 | a
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[12345]$
Description
This matches a single numeric digit between 1 and 5, and is the same as saying ^[1-5]$.
Matches
1 | 2 | 4
Non-Matches
6 | -1 | abc
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
Description
This expression matches email addresses, and checks that they are of the proper form. It checks to ensure the top level domain is between 2 and 4 characters long, but does not check the specific domain against a list (especially since there are so many of them now).
Matches
joe@aol.com | joe@wrox.co.uk | joe@domain.info
Non-Matches
a@b | notanemail | joe@@.
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[2-9]\d{2}-\d{3}-\d{4}$
Description
This expression matches a hyphen separated US phone number, of the form ANN-NNN-NNNN, where A is between 2 and 9 and N is between 0 and 9.
Matches
800-555-5555 | 333-444-5555 | 212-666-1234
Non-Matches
000-000-0000 | 123-456-7890 | 2126661234
Author Rating: The rating for this expression. Steven Smith
Title Test Details Pattern Title
Expression
^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$
Description
This expression matches three different formats of postal codes: 5 digit US ZIP code, 5 digit US ZIP code + 4, and 6 digit alphanumeric Canadian Postal Code. The first one must be 5 numeric digits. The ZIP+4 must be 5 numeric digits, a hyphen, and then 4 numeric digits. The Canadian postal code must be of the form ANA NAN where A is any uppercase alphabetic character and N is a numeric digit from 0 to 9.
Matches
44240 | 44240-5555 | G3H 6A3
Non-Matches
Ohio | abc | g3h6a3
Author Rating: The rating for this expression. Steven Smith
Title Test Details Pattern Title
Expression
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
Description
US Phone Number -- doesn't check to see if first digit is legal (not a 0 or 1).
Matches
(123) 456-7890 | 123-456-7890
Non-Matches
1234567890
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
[\w-]+@([\w-]+\.)+[\w-]+
Description
Yet another simple email validator expression.
Matches
joe@aol.com | a@b.c
Non-Matches
asdf | 1234
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
\d{4}-?\d{4}-?\d{4}-?\d{4}
Description
Major credit card validator. Only checks that the format is 16 digits (optionally separated by hyphens), not the value of any of the digits.
Matches
1234-1234-1234-1234 | 1234123412341234
Non-Matches
1234123412345
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^(?=.*\d).{4,8}$
Description
Password expression. Password must be between 4 and 8 digits long and include at least one numeric digit.
Matches
1234 | asdf1234 | asp123
Non-Matches
asdf | asdf12345 | password
Author Rating: The rating for this expression. Steven Smith
Title Test Details Pattern Title
Expression
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$
Description
Password matching expression. Password must be at least 4 characters, no more than 8 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit.
Matches
asD1 | asDF1234 | ASPgo123
Non-Matches
asdf | 1234 | ASDF12345
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
(\w+)\s+\1
Description
This expression uses a BackReference to find occurrences of the same word twice in a row (separated by a space). Matches things like 'mandate dated', which may not be desirable. See Sean Carley's update for a better expression for true repeated word matching.
Matches
hubba hubba | mandate dated | an annual
Non-Matches
may day | gogo | 1212
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^(\d{4}[- ]){3}\d{4}|\d{16}$
Description
Credit card validator. Just checks that the format is either 16 numbers in groups of four separated by a "-" or a " " or nothing at all.
Matches
1234-1234-1234-1234 | 1234 1234 1234 1234 | 1234123412341234
Non-Matches
Visa | 1234 | 123-1234-12345
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$
Description
Matches major credit cards including: Visa (length 16, prefix 4), Mastercard (length 16, prefix 51-55), Discover (length 16, prefix 6011), American Express (length 15, prefix 34 or 37). All 16 digit formats accept optional hyphens (-) between each group of four digits.
Matches
6011-1111-1111-1111 | 5423-1111-1111-1111 | 341111111111111
Non-Matches
4111-111-111-111 | 3411-1111-1111-111 | Visa
Author Rating: The rating for this expression. Steven Smith
Title Test Details Pattern Title
Expression
^.{4,8}$
Description
Matches any string between 4 and 8 characters in length. Limits the length of a string. Useful to add to password regular expressions.
Matches
asdf | 1234 | asdf1234
Non-Matches
asd | 123 | asdfe12345
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^\d*$
Description
Accepts an unsigned integer number. Also matches empty strings.
Matches
123 | 000 | 43
Non-Matches
asbc | -34 | 3.1415
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[-+]?\d*$
Description
Matches any integer number or numeric string, including positive and negative value characters (+ or -). Also matches empty strings.
Matches
123 | -123 | +123
Non-Matches
abc | 3.14159 | -3.14159
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^\d*\.?\d*$
Description
Matches any unsigned floating point number/numeric string. Also matches empty strings.
Matches
123 | 3.14159 | .234
Non-Matches
abc | -3.14159 | 3.4.2
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[-+]?\d*\.?\d*$
Description
Matches any floating point numer/numeric string, including optional sign character (+ or -). Also matches empty strings.
Matches
123 | +3.14159 | -3.14159
Non-Matches
abc | 3.4.5 | $99.95
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^\d{9}[\d|X]$
Description
A very simple ISBN validation expression - it just checks for a 10 digit number where the last digit could also be a capital 'X'. Complete specs for ISBN available here: http://www.isbn.org/standards/home/isbn/international/html/usm4.htm. An enhancement would be to allow exactly 3 or 0 hyphens or 3 or 0 spaces, since these are also valid formats.
Matches
1234123412 | 123412341X
Non-Matches
not an isbn
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^(20|21|22|23|[0-1]\d)[0-5]\d$
Description
This regular expression will match a 24 hour time with no separators.
Matches
1200 | 1645 | 2359
Non-Matches
2400 | asbc | 12:45
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^( [1-9]|[1-9]|0[1-9]|10|11|12)[0-5]\d$
Description
Matches a 12-hour time value expressed as either 4 numeric digits, 3 numeric digits, or a space and 3 numeric digits. 3 digit times (930) can be expressed with leading 0's (0930) or not. AM/PM designation is not included in this expression.
Matches
1145 | 933 | 801
Non-Matches
0000 | 1330 | 8:30
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^(|(0[1-9])|(1[0-2]))\/((0[1-9])|(1\d)|(2\d)|(3[0-1]))\/((\d{4}))$
Description
This expression matches dates formatted as MM/DD/YYYY where months and days must be 2 digits each, zero padded. It is not perfect - it allows DD to be from 01 to 31 regardless of the month.
Matches
01/01/2001 | 02/30/2001 | 12/31/2002
Non-Matches
1/1/02 | 1/1/2002 | 1/25/2002
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^((((0[13578])|(1[02]))[\/]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\/]?(([0-2][0-9])|(30)))|(02[\/]?[0-2][0-9]))[\/]?\d{4}$
Description
Date expressions that matches MM/DD/YYYY where MM and DD must be two digits and zero padded. Validates correctly for all months except February, which it assumes to always have 29 days. The "/" separator is optional.
Matches
01/01/2001 | 02/29/2002 | 12/31/2002
Non-Matches
1/1/02 | 02/30/2002 | 1/25/2002
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^[-+]?\d+(\.\d+)?$
Description
This matches any real number, with optional decimal point and numbers after the decimal, and optional positive (+) or negative (-) designation.
Matches
123 | -123.45 | +123.56
Non-Matches
123x | .123 | -123.
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
[A-Z][a-z]+
Description
This expression was developed to match the Title cased words within a Camel cased variable name. So it will match 'First' and 'Name' within 'strFirstName'.
Matches
strFirstName | intAgeInYears | Where the Wild Things Are
Non-Matches
123 | abc | this has no caps in it
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
\.com/(\d+)$
Description
This is a regex I wrote to capture requests to AspAlliance.com with an article id as the only thing after the domain. So http://aspalliance.com/123 would go to article number 123. It maps the URL to the actual aspx file that displays the article based on the ID.
Matches
http://aspalliance.com/123 | www.aspalliance.com/123 | http://aspalliance.com/34
Non-Matches
http://aspalliance.com/article.aspx?id=123 | http://aspalliance.com/ | http://aspalliance.com/articl
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
^DOMAIN\\\w+$
Description
In response to a question on the regex list at www.aspadvice.com, this expression should ensure that a login field's username includes a 'DOMAIN\' prefix. The latter part of the expression should probably be limited so that it only allows usernames of appropriate lengths, perhaps 3 to 20 characters (by replacing + with {3,20} for instance).
Matches
DOMAIN\ssmith | DOMAIN\a | DOMAIN\username
Non-Matches
ssmith | username | DOMAIN\
Author Rating: Not yet rated. Steven Smith
Title Test Details Price
Expression
^[$]?[0-9]*(\.)?[0-9]?[0-9]?$
Description
Should match prices with or without a dollar sign.
Matches
4.42 | $4.42
Non-Matches
asdf
Author Rating: The rating for this expression. Steven Smith
Title Test Details Image File Extension
Expression
.*(\.[Jj][Pp][Gg]|\.[Gg][Ii][Ff]|\.[Jj][Pp][Ee][Gg]|\.[Pp][Nn][Gg])
Description
This expression should work to validate that an uploaded file's extension is either jpg, gif, or png.
Matches
foo.gif|foo.jpg|foo.png
Non-Matches
foo.txt|foo.zip|foo.exe
Author Rating: Not yet rated. Steven Smith
Change page:   |    Displaying page 1 of 3 pages; Items 1 to 20

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