104 regular expressions found in this category!
Displaying page
of
pages;
Items to
| Title |
Test
Details
Validate US Postal Code
|
| Expression |
^(?!00000)(?<zip>(?<zip5>\d{5})(?:[ -](?=\d))?(?<zip4>\d{4})?)$ |
| Description |
Validate US zip codes. Matches all zip codes of exactly 5 digits except 00000. Optionally, matches zip5+zip4 where zip5 is exactly 5 digits, zip4 is exactly 4 digits, and zip5 and zip4 are, optionally, separated by a single space or hyphen. Captures zip5 and zip4 to named groups to facilitate program manipulation. |
| Matches |
12345 | 123456789 | 12345-6789 |
| Non-Matches |
12345- | 00000 | 00000-6789 |
| Author |
Rating:
Jerry Schmersahl
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[\\(]{0,1}([0-9]){3}[\\)]{0,1}[ ]?([^0-1]){1}([0-9]){2}[ ]?[-]?[ ]?([0-9]){4}[ ]*((x){0,1}([0-9]){1,5}){0,1}$ |
| Description |
US Telephone Number where this is regular expression excludes the first number, after the area code,from being 0 or 1; it also allows an extension
to be added where it does not have to be prefixed by 'x'. |
| Matches |
(910)456-7890 | (910)456-8970 x12 | (910)456-8970 1211 |
| Non-Matches |
(910) 156-7890 | (910) 056-7890 | (910) 556-7890 x |
| Author |
Rating:
Bill Anderson
|
| Title |
Test
Details
Phone Numbers
|
| Expression |
^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$ |
| Description |
This regular expressions matches phone numbers with area codes and optional US country code and optional phone extension. User have so many ways of entering phone numbers into input fields. This allows for some of the ones I've encountered. Feel free to contact me if you find ones that do not match. |
| Matches |
2405525009 | 1(240) 652-5009 | 240/752-5009 ext.55 |
| Non-Matches |
(2405525009 | 2 (240) 652-5009 |
| Author |
Rating:
Dean Dal Bozzo
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[+][0-9]\d{2}-\d{3}-\d{4}$ |
| Description |
This is a basic telephone number vaildation which needs a compulsory prefix of a '+' sign with three digits and followed by a hipen, another three digits and finally followed by another hipen and four more digits.
Regards,
Senthil Gunabalan |
| Matches |
+974-584-5656 | +000-000-0000 | +323-343-3453 |
| Non-Matches |
974-584-5656 | +974 000 0000 |
| Author |
Rating:
Senthil Gunabalan
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[0-9]{2,3}-? ?[0-9]{6,7}$ |
| Description |
Validates Spain Phones |
| Matches |
972367087 | 97-3770866 | 972-377086 |
| Non-Matches |
9988-989898 | 989898988989 | 9 9898989898 |
| Author |
Rating:
Francesc Vila
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(((^[BEGLMNS][1-9]\d?)|(^W[2-9])|(^(A[BL]|B[ABDHLNRST]|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]|F[KY]|G[LUY]|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]|M[EKL]|N[EGNPRW]|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKL-PRSTWY]|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)\d\d?)|(^W1[A-HJKSTUW0-9])|(((^WC[1-2])|(^EC[1-4])|(^SW1))[ABEHMNPRVWXY]))(\s*)?([0-9][ABD-HJLNP-UW-Z]{2}))$|(^GIR\s?0AA$) |
| Description |
For the terminally hard of thinking, a version of my UK postcode validator without WHITESPACE. Unlike most validators on regexlib, this knows valid postcode combinations, e.g. W1A is permitted, W1 is not, but W2 is. It should catch between 95-98% of invalid postcodes. |
| Matches |
W1A 1AA | EC1V1JN | N7 8BQ |
| Non-Matches |
W1A 1AM | BM1 1AB | EC1 1AA |
| Author |
Rating:
Howard Richards
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$ |
| Description |
Matches US phone number format. 1 in the beginning is optional, area code is required, spaces or dashes can be used as optional divider between number groups. Also alphanumeric format is allowed after area code. |
| Matches |
1-(123)-123-1234 | 123 123 1234 | 1-800-ALPHNUM |
| Non-Matches |
1.123.123.1234 | (123)-1234-123 | 123-1234 |
| Author |
Rating:
Igor Kravtsov
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(((^[BEGLMNS][1-9]\d?) | (^W[2-9] ) | ( ^( A[BL] | B[ABDHLNRST] | C[ABFHMORTVW] | D[ADEGHLNTY] | E[HNX] | F[KY] | G[LUY] | H[ADGPRSUX] | I[GMPV] | JE | K[ATWY] | L[ADELNSU] | M[EKL] | N[EGNPRW] | O[LX] | P[AEHLOR] | R[GHM] | S[AEGKL-PRSTWY] | T[ADFNQRSW] | UB | W[ADFNRSV] | YO | ZE ) \d\d?) | (^W1[A-HJKSTUW0-9]) | (( (^WC[1-2]) | (^EC[1-4]) | (^SW1) ) [ABEHMNPRVWXY] ) ) (\s*)? ([0-9][ABD-HJLNP-UW-Z]{2})) | (^GIR\s?0AA) |
| Description |
Here it is, the monster UK Postcode regular expression that should prevent the majority of miskeying. Unlike an most other regexes it only permits valid combinations of letters, e.g. BN works, BM does not. Spaces between the first and second parts are optional. I have tested this against a file of 7,500 valid postcodes, and also against a real-world list of about 12,000 which had some bad data. Manually checking a sample of the rejected ones showed it was working correctly (and how poor the data was!!).
I originally started by trying to adapt the GDSC document at http://www.govtalk.gov.uk/gdsc/html/frames/PostCode.htm and specifically their XSD pattern at http://www.govtalk.gov.uk/gdsc/schemaHtml/bs7666-v2-0-xsd-PostCodeType.htm but this turned out to be rather loose. Instead I wrote this. If you find any valid postcodes being rejected by this regex please let me know. |
| Matches |
W1A 1AA | EC2V 1JN | GIR 0AA |
| Non-Matches |
TB12 1AB | EC2V 1JM | W2A 1AA |
| Author |
Rating:
Howard Richards
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^\(\d{3}\) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4} |
| Description |
Expresion Regular para Teléfonos con clave lada en México
separada o no con guiones o espacios. Sirve para teléfonos estacionarios y/o celulares, con o sin paréntesis, 10 números a fuerzas, funciona en .net |
| Matches |
(658)154-1122 | 6581541122 | 658-154-1122 |
| Non-Matches |
(658 154 1122 | 759-1245 | 875 (489 1568) |
| Author |
Rating:
Alex Cons
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^p(ost)?[ |\.]*o(ffice)?[ |\.]*(box)?[ 0-9]*[^[a-z ]]* |
| Description |
This expression is useful for determining if an address is a PO Box type address. This can be useful in shipping systems as well as other systems that need to make determinations based on the type of address imputed. |
| Matches |
po box 4353 |
| Non-Matches |
pollo St. | P. O. Box d3f12s | BOX 23 |
| Author |
Rating:
Darryl Kuhn
|
| Title |
Test
Details
U.S. Street Address
|
| Expression |
^(?n:(?<address1>(\d{1,5}(\ 1\/[234])?(\x20[A-Z]([a-z])+)+ )|(P\.O\.\ Box\ \d{1,5}))\s{1,2}(?i:(?<address2>(((APT|B LDG|DEPT|FL|HNGR|LOT|PIER|RM|S(LIP|PC|T(E|OP))|TRLR|UNIT)\x20\w{1,5})|(BSMT|FRNT|LBBY|LOWR|OFC|PH|REAR|SIDE|UPPR)\.?)\s{1,2})?)(?<city>[A-Z]([a-z])+(\.?)(\x20[A-Z]([a-z])+){0,2})\, \x20(?<state>A[LKSZRAP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADL N]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD] |T[NX]|UT|V[AIT]|W[AIVY])\x20(?<zipcode>(?!0{5})\d{5}(-\d {4})?))$ |
| Description |
captures US street address.
Address format: ##### Street 2ndunit City, ST zip+4
address1 - must have street number and proper case street name. no punctuation or P.O Box #### punctuation manditory for P.O.
address2 - optional secondary unit abbr. Secondary range required for some units.
City - Proper case city name.
State - State abbreviation. All caps
zip - zip+4. Can't be all zeroes
Abbreviations for secondary units and States are those used by the US Postal Service.
http://www.usps.com/ncsc/lookups/usps_abbreviations.html
Certain secondary units require a secondary range, see the above link
THis RE isn't unbreakable, Probably will allow some false positives but should work for most addresses. |
| Matches |
123 Park Ave Apt 123 New York City, NY 10002 | P.O. Box 12345 Los Angeles, CA 12304 |
| Non-Matches |
123 Main St | 123 City, State 00000 | 123 street city, ST 00000 |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(\d{2}-\d{2})*$ |
| Description |
This expression is a simplex expression that checks to see if a value is a valid phone system terminal number. It allows a null value or 2 digits, dash, 2 digits. Written by Jason N. Gaylord. |
| Matches |
00-00 | 54-68 |
| Non-Matches |
1235 | 0 | 5-789 |
| Author |
Rating:
Jason N. Gaylord
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(^(?!0{5})(\d{5})(?!-?0{4})(-?\d{4})?$) |
| Description |
Javascript matches US zipcodes not allowing all zeros in first 5 or +4 |
| Matches |
12345 | 12345-6789 | 123456789 |
| Non-Matches |
12345-0000 | 00000-0000 | 00000 |
| Author |
Rating:
Justin Elsberry
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$ |
| Description |
U. S. or Canadian telephone number regular expression. <BR>
<BR>
// # Checks phone numbers for validity <BR>
// [01]? # optional '0', or '1' <BR>
// [- .]? # optional separator is either a dash, a space, or a period. <BR>
// \(? # optional parentheses <BR>
// [2-9] # first # of the area code must not be a '0' or '1' <BR>
// \d{2} # next 2 digits of area code can be 0-9 <BR>
// \)? # optional parentheses <BR>
// [- .]? # optional separator is either a dash, a space, or a period. <BR>
// \d{3} # 3-digit prefix <BR>
// [- .]? # optional separator is either a dash, a space, or a period. <BR>
// \d{4} # 4-digit station number <BR>
|
| Matches |
18008793262 | 800-879-3262 | 0-800.879.3262 |
| Non-Matches |
879 3262 | 077 879 3262 | 879-3262 |
| Author |
Rating:
W. D.
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(\d{3}-\d{3}-\d{4})*$ |
| Description |
This expression is a very simplex expression that allows null values or 3 digits, dash, 3 digits, dash, 4 digits. It validates a basic US phone number. Written by Jason N. Gaylord. |
| Matches |
555-555-1212 | 123-456-7890 |
| Non-Matches |
555.555.1212 | (555) 555-1212 | 5555551212 |
| Author |
Rating:
Jason N. Gaylord
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([\+][0-9]{1,3}[\.][0-9]{1,12})([x]?[0-9]{1,4}?)$ |
| Description |
Validates on the following standards:
+CCC.ZZZZZZZZZZxYYYY, where 'C' is the numeric
country phone code (up to three digits), 'Z' is the phone number (up to
12 digits) and 'Y' is the extension (up to 4 digits); max length overall is
20 characters, including the '+', '.', and 'x' (if extension is present).
Useful for people communicating with the OpenSRS API |
| Matches |
+800.4453377x4444 | +80.4453377 | +8.123456789123x1111 |
| Non-Matches |
181823884499 | +800.4453377x | 2486994x11 |
| Author |
Rating:
Hayk A
|
| 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:
Steven Smith
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[0-9]{6} |
| Description |
I know its simple, yet there was no Russian postal code regular expression on the RegExLib. Just in case some needs to know the format. |
| Matches |
150016 |
| Non-Matches |
qqww |
| Author |
Rating:
Roman Lukyanenko
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[D-d][K-k]-[1-9]{1}[0-9]{3}$ |
| Description |
Postalcode Danmark |
| Matches |
Dk-1234 | dk-1234 | DK-1234 |
| Non-Matches |
DK 1234 | DK 12345 |
| Author |
Rating:
paul Snabilie
|
Displaying page
of
pages;
Items to