Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
^\d{3}-\d{2}-\d{4}$ |
Description |
This regular expression will match a hyphen-separated Social Security Number (SSN) in the format NNN-NN-NNNN. |
Matches |
333-22-4444 | 123-45-6789 |
Non-Matches |
123456789 | SSN |
Author |
Rating:
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:
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:
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:
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^\s*[a-zA-Z,\s]+\s*$ |
Description |
Any Expression Upper/Lower Case, with commas and space between the text, with any amount of space before or after |
Matches |
Smith, Ed | Ed Smith | aBcDeFgH |
Non-Matches |
a123 | AB5 | Mr. Ed |
Author |
Rating:
Not yet rated.
Mart Maasikas
|
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 |
^((?:4\d{3})|(?:5[1-5]\d{2})|(?:6011)|(?:3[68]\d{2})|(?:30[012345]\d))[ -]?(\d{4})[ -]?(\d{4})[ -]?(\d{4}|3[4,7]\d{13})$ |
Description |
This just a minor mod to Steven Smith's credit card re to accept spaces as separators, as well as return the four parts of the card. [Updated Oct-18-2002 to work with Diners Club/Carte Blanche (prefix must be 36, 38, or 300-305)] |
Matches |
6011567812345678 | 6011 5678 1234 5678 | 6011-5678-1234-5678 |
Non-Matches |
1234567890123456 |
Author |
Rating:
Glenn Carr
|
Title |
Test
Details
Pattern Title
|
Expression |
"((\\")|[^"(\\")])+" |
Description |
Matches quoted string, using \" as an escape to place quotes in the string |
Matches |
"test" | "escape\"quote" | "\"" |
Non-Matches |
test | "test | "test\" |
Author |
Rating:
Alessandro Vergani
|
Title |
Test
Details
Pattern Title
|
Expression |
^([1-zA-Z0-1@.\s]{1,255})$ |
Description |
A general string validation to insure no malicious code is being passed through user input. General enough too allow email address, names, address, passwords, so on. Disallows ‘,\*&$<> or other characters that could cause issues. |
Matches |
|
Non-Matches |
‘,\*&$<> | 1001' string |
Author |
Rating:
Not yet rated.
Paul Miller
|
Title |
Test
Details
Pattern Title
|
Expression |
^([A-Z]{1}[a-z]{1,})$|^([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$|^([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$|^$ |
Description |
Matches up to three alphabet words separated by spaces with first alphabet character of each word uppercase. Also matches empty strings. |
Matches |
Sacramento | San Francisco | San Luis Obispo |
Non-Matches |
SanFrancisco | SanLuisObispo | San francisco |
Author |
Rating:
Don Batchelor
|
Title |
Test
Details
Pattern Title
|
Expression |
(^|\s)(00[1-9]|0[1-9]0|0[1-9][1-9]|[1-6]\d{2}|7[0-6]\d|77[0-2])(-?|[\. ])([1-9]0|0[1-9]|[1-9][1-9])\3(\d{3}[1-9]|[1-9]\d{3}|\d[1-9]\d{2}|\d{2}[1-9]\d)($|\s|[;:,!\.\?]) |
Description |
Incorporated other people's examples; removed extraneous parenthesis on 10/7/04. Currently the SSA site says 772 is the highest AREA number generated (http://www.ssa.gov/employer/highgroup.txt). Old expression was: (^|\s)\d{3}(-?|[\. ])\d{2}\2\d{4}($|\s|[;:,!\.\?]). Looks for either the beginning of a line or whitespace before the beginning of the social security number, then either zero or one hyphen OR one of a period or space, then uses the \3 to reference the value returned in the parenthesis that includes the -?|[\. ] (basically says if the first dash, period, or space is there, then the second one is required; and if the first dash, period, or space is not there, then the second one can't be either), and finally looks for the end of a line, whitespace, or punctuation characters after the social security number. |
Matches |
123-45-6789 | 123 45 6789 | 123456789 |
Non-Matches |
12345-67-890123 | 1234-56-7890 | 123-45-78901 |
Author |
Rating:
Dennis Flynn
|
Title |
Test
Details
Pattern Title
|
Expression |
<[^>]+> |
Description |
This expression finds all opening and closing tags. Good for stripping out tags in an XML or HTML document.
I used it to clean-up HTML documents that had XML mixed in. It found all the tags, then I just deleted the ones that weren't standard. I used it in HOMESITES extended find. |
Matches |
<html> | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | < |
Non-Matches |
Any plain old text | http://www.regexlib.com/Add.aspx | xml> |
Author |
Rating:
X Man
|
Title |
Test
Details
Pattern Title
|
Expression |
^[0-9]{1,}(,[0-9]+){0,}$ |
Description |
It could be use to validate html input form (checkbox, optionbox, selectbox) when you have multiple numeric value under one field name. The validation is that the user have at lease chose one or more! |
Matches |
1111 | 47,26,2,1,1111,12 | 25,1245,2122,23232 |
Non-Matches |
111, | 1a1,111,1212,23 | 11aa,aaa,asas,asa |
Author |
Rating:
Nicholas Rathwell
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*<>:\;|\"/]+$ |
Description |
Additional checks for <> and " characters |
Matches |
abc |
Non-Matches |
PRN |
Author |
Rating:
Not yet rated.
Rahul Pandit
|
Title |
Test
Details
Pattern Title
|
Expression |
^([a-z0-9]+([\-a-z0-9]*[a-z0-9]+)?\.){0,}([a-z0-9]+([\-a-z0-9]*[a-z0-9]+)?){1,63}(\.[a-z0-9]{2,7})+$ |
Description |
[Note: this regex was tested with Macromedia's ColdFusion MX. I'm sure it'll need some massaging to work with other regex engines.] Of the few domain validating regular expressions I found in my search I didn't find a single one that reliably handled multiple levels of subdomains or TLDs. So, I wrote one and thoroughly tested it. There are a ton of matching and non-matching examples that need to be included to show the completeness of this regex.
Non-matching: -.domain.com, -a.domain.com, -domain.com, domain-.com, any domain where the portion before the tld is greater than 63 characters.
Matching: a.domain.com, a-a.domain.com, a--a.domain.com, a--defg.com, domain.co.uk. |
Matches |
800-med-alert.com | jump.to | archive-3.www.regexlib.com |
Non-Matches |
example | a-.domain.com | http://regexlib.com/ |
Author |
Rating:
Not yet rated.
Jeff Howden
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?![0-9]{6})[0-9a-zA-Z]{6}$ |
Description |
matches a six character "password" that has to consist of numbers and letters with at least one letter in it. |
Matches |
123a12 | a12345 | aaaaaa |
Non-Matches |
111111 |
Author |
Rating:
Not yet rated.
James T. Kirk
|
Title |
Test
Details
Pattern Title
|
Expression |
(NOT)?(\s*\(*)\s*(\w+)\s*(=|<>|<|>|LIKE|IN)\s*(\(([^\)]*)\)|'([^']*)'|(-?\d*\.?\d+))(\s*\)*\s*)(AND|OR)? |
Description |
Heres my sql clause parser regexp for recordset filtering. Does recursive query parsing all by its self. Only problem I cant figure is how to match comma separated lists of quoted strings. Tell me if you figure out how!
The unicodes in the re was put in by the entry form please replace them with their ascii equivalents to use it. |
Matches |
Aeroplane LIKE 767 | Movie LIKE 'Star' AND NOT Movie LIKE 'Trek' | Number IN (1,2,3,4,5) |
Non-Matches |
Hello there | A=EXCELLENT OR | B!=POOR |
Author |
Rating:
Not yet rated.
Joseph Warwick
|
Title |
Test
Details
Pattern Title
|
Expression |
(?s)(?:\e\[(?:(\d+);?)*([A-Za-z])(.*?))(?=\e\[|\z) |
Description |
This expression will match all of the commands(escape codes) used in ANSI files. These are what were used to create the colors/blocks on BBS's for those of us that once dialed into them.
http://www.wikipedia.org/wiki/ANSI_escape_code has a reference for ANSI escape codes.
http://idledreams.net/lordscarlet/posts/153.aspx shows an example of the engine I have created surrounding the expression |
Matches |
[32mHello | [1;35mTest | [2J |
Non-Matches |
abc |
Author |
Rating:
Not yet rated.
Doug Moore
|
Displaying page
of
pages;
Items to