104 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
^(?:(?<1>[(])?(?<AreaCode>[2-9]\d{2})(?(1)[)][ ]?|[- \/.]?))?
(?<Prefix>[1-9]\d{2})[- .]?(?<Suffix>\d{4})
(?:(?:[ ]+|[xX]|Ext\.?[ ]?){1,2}(?<Ext>\d{1,5}))?$ |
Description |
PCRE (PHP) regular expression for validating US telephone numbers with OPTIONAL area code, and OPTIONAL extension. Promiscuous formatting (parenthesis or slash, space, dash, dot or no separator). Captures the telephone number area code, prefix, suffix, and extension to named groups. Rejects area codes that begin with 0 or 1 and prefixes that begin with 0. Rejects all telephone numbers that do not match on exactly 7 digits, or on exactly 10 digits with the optional area code, not counting the extension or the format. Seperators, when used, must be in the right place. Extension can be preceded by a space(s) and/or "x", "X", or "Ext" and matches on 1 to 5 digits.
Written from the view that getting phone numbers from customers should be as easy and tolerant as possible. Matched number can be parsed and entered into database correctly on the business end.
Based on similar regex by Jerry Schmersahl in this library. Case insensitivity could simplify this expression, but implementation is left up to you.
For PHP/PCRE compatibility, put a "P" in front of each capture name (ie: "(?P<AreaCode>"). This server does not recognize the Python/PCRE naming convention. |
Matches |
785/3215564x51337 | (785)321-5564 Ext. 51337 | 321.5564 x5 |
Non-Matches |
785321556 | (785)321-5564 x | 7853 215567 |
Author |
Rating:
Not yet rated.
Bret Greenwood
|
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:
Not yet rated.
Darryl Kuhn
|
Title |
Test
Details
Pattern Title
|
Expression |
(\+)?([-\._\(\) ]?[\d]{3,20}[-\._\(\) ]?){2,10} |
Description |
Telephone number filter - use to catch and replace phone numbers where you don't want them to appear. |
Matches |
(604) 789-0136 | +123-45678-908 |
Non-Matches |
01.12.23 |
Author |
Rating:
Not yet rated.
Dave Turner
|
Title |
Test
Details
Pattern Title
|
Expression |
^(\()?(787|939)(\)|-)?([0-9]{3})(-)?([0-9]{4}|[0-9]{4})$ |
Description |
Filter US telephone numbers. This particular one accepts only area code 939 or 787. Area code parentesis or hyphens optional. |
Matches |
(787)755-0114 | 939-315-0112 | 7879093849 |
Non-Matches |
(098)737-3942 | (89)893-2392 | 939782721 |
Author |
Rating:
Not yet rated.
Ricardo Gonzalez
|
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:
Not yet rated.
Francesc Vila
|
Title |
Test
Details
Pattern Title
|
Expression |
^0{0,1}[1-9]{1}[0-9]{2}[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{6}$ |
Description |
The regex that matches the telephone numbers in India.
####Enjoy Regex#### |
Matches |
0493 - 3227341 | 0493 3227341 | 493 3227341 |
Non-Matches |
93 0227341 | 493 322734111 | 493 -- 3227341 |
Author |
Rating:
Not yet rated.
Vathachira Joseph Bino
|
Title |
Test
Details
Pattern Title
|
Expression |
^[0-9]{5}([\s-]{1}[0-9]{4})?$ |
Description |
My first Expression. This will match US postal codes (zip codes) using simple 5 digit format with optional 4 digit extention seperated by a space or hyphen. Will not accept letters.
example: 12345 or 12345-1234 or 12345 1234. |
Matches |
12345-1234 | 12345 | 12345 1234 |
Non-Matches |
123451234 | 12345 a345 | a2345-1234 |
Author |
Rating:
Not yet rated.
Ed Stafford
|
Title |
Test
Details
Pattern Title
|
Expression |
((\(\d{3}\) ?)|(\d{3}[- \.]))?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$ |
Description |
This will match US most common telephones format with extension or with out extension. Works with both Java and .NET. |
Matches |
(123) 456-7890 | (123) 456-7890 x123 |
Non-Matches |
(123) 456-7890 x123x | (123) 456-7890 x123 x123 | (123) 456-7890 x |
Author |
Rating:
Not yet rated.
khoi le
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?:\([2-9]\d{2}\)\ ?|(?:[2-9]\d{2}\-))[2-9]\d{2}\-\d{4}$ |
Description |
This US phone number edit with restricted format options: Accepts optional parens on area code with or without following space, and dashes between area code, central office code and station code. Formats include only (222) 555-1212 (with or without a space) and 222-555-1212. Conforms to NANP A-digit and D-digit requirements (ANN-DNN-NNNN). Area Codes 001-199 are not permitted; Central Office Codes 001-199 are not permitted. |
Matches |
(234) 555-1212 | (234)555-1212 | 234-555-1212 |
Non-Matches |
(234)5551212 | 234 555 1212 | 234) 555-1212 |
Author |
Rating:
Not yet rated.
Don Johnston
|
Title |
Test
Details
Pattern Title
|
Expression |
^([0-9]*\-?\ ?\/?[0-9]*)$ |
Description |
Match italian telephone number with prefix followed by "/", "-" or blank and number. Usefull with numeric keybord! |
Matches |
02-343536 | 02/343536 | 02 343536 |
Non-Matches |
02a343536 | 02+343536 |
Author |
Rating:
Not yet rated.
Giorgio Spugnesi
|
Title |
Test
Details
Pattern Title
|
Expression |
(\s*\(?0\d{4}\)?(\s*|-)\d{3}(\s*|-)\d{3}\s*)|(\s*\(?0\d{3}\)?(\s*|-)\d{3}(\s*|-)\d{4}\s*)|(\s*(7|8)(\d{7}|\d{3}(\-|\s{1})\d{4})\s*) |
Description |
another uk telephone number regex. This was adapted from another on this site http://www.regexlib.com/REDetails.aspx?regexp_id=297
I added support for hyphens and for london shorthand numbers ie. 8234-1234 72341234 Still want to be permissive where possible....Still need to sort out the all zeros, also not sure if numbers with 4 digits followed by 7 used in london 0208-234-1234 is the area of the uk where this occurs, or all areas outside of london are in format 5 digits followed by 6 digits ie. 01608 123456. If that is the case for the 4-7 pattern only 0208 or 0207 could be enforced. |
Matches |
0208 993 5689 | 0208-993-5689 | 89935689 |
Non-Matches |
1608 123 456 |
Author |
Rating:
Not yet rated.
Matt Baskey
|
Title |
Test
Details
Pattern Title
|
Expression |
^[0-9]{5}$ |
Description |
Matches german standard postal codes named 'Postleitzahl' |
Matches |
03242 | 36260 | 12394 |
Non-Matches |
3520 | 102 | 100202 |
Author |
Rating:
Not yet rated.
Kevin Wennemuth
|
Title |
Test
Details
Pattern Title
|
Expression |
^[abceghjklmnprstvxyABCEGHJKLMNPRSTVXY][0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ] {0,1}[0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ][0-9]$ |
Description |
Canadian Postal Code / Codes / Canada / Zip
Google for DFIOQU and you'll see where I got the
info for this.
Can anyone simplify this?
|
Matches |
G3M 5T9 | C3M5T9 |
Non-Matches |
Z3M 5T9 | W3M 5T9 | 5T9 C3M |
Author |
Rating:
Not yet rated.
W. D.
|
Title |
Test
Details
Pattern Title
|
Expression |
(^(p[\s|\.|,]*|
^post[\s|\.]*)(o[\s|\.|,]*|
office[\s|\.]*))|
(^box[.|\s]*\d+) |
Description |
This expression filters all variations of Post Office Box or PO Box. |
Matches |
PO Box | p.o. box | box 123 |
Non-Matches |
123 Some Street |
Author |
Rating:
Not yet rated.
Joseph Lamb
|
Title |
Test
Details
Pattern Title
|
Expression |
^\([0-9]{3}\)\s?[0-9]{3}(-|\s)?[0-9]{4}$|^[0-9]{3}-?[0-9]{3}-?[0-9]{4}$ |
Description |
US telephone check |
Matches |
1231231234 | (123)123-1234 | 123-123-1234 |
Non-Matches |
12312312345 | (123)-123-1234 | 123 |
Author |
Rating:
Not yet rated.
PJ Bijoy
|
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:
Not yet rated.
Justin Elsberry
|
Title |
Test
Details
Pattern Title
|
Expression |
^\s*((?:(?:\d+(?:\x20+\w+\.?)+(?:(?:\x20+STREET|ST|DRIVE|DR|AVENUE|AVE|ROAD|RD|LOOP|COURT|CT|CIRCLE|LANE|LN|BOULEVARD|BLVD)\.?)?)|(?:(?:P\.\x20?O\.|P\x20?O)\x20*Box\x20+\d+)|(?:General\x20+Delivery)|(?:C[\\\/]O\x20+(?:\w+\x20*)+))\,?\x20*(?:(?:(?:APT|BLDG|DEPT|FL|HNGR|LOT|PIER|RM|S(?:LIP|PC|T(?:E|OP))|TRLR|UNIT|\x23)\.?\x20*(?:[a-zA-Z0-9\-]+))|(?:BSMT|FRNT|LBBY|LOWR|OFC|PH|REAR|SIDE|UPPR))?)\,?\s+((?:(?:\d+(?:\x20+\w+\.?)+(?:(?:\x20+STREET|ST|DRIVE|DR|AVENUE|AVE|ROAD|RD|LOOP|COURT|CT|CIRCLE|LANE|LN|BOULEVARD|BLVD)\.?)?)|(?:(?:P\.\x20?O\.|P\x20?O)\x20*Box\x20+\d+)|(?:General\x20+Delivery)|(?:C[\\\/]O\x20+(?:\w+\x20*)+))\,?\x20*(?:(?:(?:APT|BLDG|DEPT|FL|HNGR|LOT|PIER|RM|S(?:LIP|PC|T(?:E|OP))|TRLR|UNIT|\x23)\.?\x20*(?:[a-zA-Z0-9\-]+))|(?:BSMT|FRNT|LBBY|LOWR|OFC|PH|REAR|SIDE|UPPR))?)?\,?\s+((?:[A-Za-z]+\x20*)+)\,\s+(A[LKSZRAP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])\s+(\d+(?:-\d+)?)\s*$ |
Description |
Based on a regular expression from Michael Ash, this captures US street addresses and mailing addresses, single or multi-line (multi-line is more reliable), and breaks them into discrete parts for address line 1 and 2, city, state, and postal code. This expression is not perfect - with the interpreter I am using, some addresses refuse to match correctly. It should however work for most addresses, particularly when lines are delimited with carriage returns, tabs, or some other whitespace line delimiter that is not a space (\x20). Note: For improved compatibility, this expression does not use named groups.
**Output**
\1 = Address 1,
\2 = Address 2,
\3 = City,
\4 = State,
\5 = Postal Code |
Matches |
P.O. Box 42 Huslia, AK 99746 | C/O John Paul, POBox 456, Motown, CA 96090 |
Non-Matches |
4321 East 40th Apt #3 Anchorage AK 99504 | Stockton, CA 95215 |
Author |
Rating:
Not yet rated.
Ross Hammer
|
Title |
Test
Details
Pattern Title
|
Expression |
(077|078|079)\s?\d{2}\s?\d{6} |
Description |
Validates UK mobile phone numbers. Valid formats are `077', `078' or `079' followed by another 8 digits, with an optional space after the dialling code and/or between the 4th and 5th characters of the remainder of the number. These formats are taken from the official guidelines from Ofcom, the organisation responsible for UK telecoms issues. Brackets are not valid and STD code must be entered. |
Matches |
07713 345678 | 078 12345678 | 079 12345678 |
Non-Matches |
02344 123456 | 0121 292929 | 012345 6789 |
Author |
Rating:
Not yet rated.
John Chivers
|
Title |
Test
Details
Pattern Title
|
Expression |
^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$ |
Description |
US Telephone Reg expression that allows 7, 10 or 11 digits with or without hyphens. |
Matches |
15615552323 | 1-561-555-1212 | 5613333 |
Non-Matches |
1-555-5555 | 15553333 | 0-561-555-1212 |
Author |
Rating:
Not yet rated.
jay gann
|
Displaying page
of
pages;
Items to