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

Please support RegExLib Sponsors

Sponsors

Advanced Search

Keywords

Category

Minimum Rating

Results per Page

Search Results: 15 regular expressions found.

   Displaying page 1 of 1 pages; Items 1 to 15
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 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{5}(-\d{4})?$
Description
Matches standard 5 digit US Zip Codes, or the US ZIP + 4 Standard.
Matches
48222 | 48222-1746
Non-Matches
4632 | Blake | 37333-32
Author Rating: The rating for this expression. Blake Facey
Title Test Details Pattern Title
Expression
^((\d{5}-\d{4})|(\d{5})|([A-Z]\d[A-Z]\s\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 | T2P 3C7
Non-Matches
44240ddd | t44240-55 | t2p3c7
Author Rating: The rating for this expression. Qing Jiang
Title Test Details Pattern Title
Expression
^(?(^00000(|-0000))|(\d{5}(|-\d{4})))$
Description
US zip code expression that disallows 00000 or 00000-0000 for either ZIP or ZIP+4. Great for web site validation.
Matches
12345 | 12345-6789
Non-Matches
00000 | 00000-0000 | a4650-465s
Author Rating: The rating for this expression. Paul Duncan
Title Test Details Pattern Title
Expression
^[0-9]{5}([- /]?[0-9]{4})?$
Description
US Zip Code + 4 digit extension Postal Code
Matches
14467 | 144679554 | 14467-9554
Non-Matches
14467 955 | 14467- | 1446-9554
Author Rating: The rating for this expression. Chris Weidert
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: Not yet rated. Jerry Schmersahl
Title Test Details US Zip Code
Expression
^(\d{5}(?:\-\d{4})?)$
Description
Just for US zip codes. Very simple but effective regex for verifying a number that resembles a zip code. The post office number is optional.
Matches
12345 | 12345-6789
Non-Matches
1234 | 123456 | 12345-123 | 12345-12345
Author Rating: The rating for this expression. tedcambron
Title Test Details Canada Postal Codes
Expression
^(?<full>(?<part1>[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1})(?:[ ](?=\d))?(?<part2>\d{1}[A-Z]{1}\d{1}))$
Description
This is a combination of Jerry Schmersahl's (http://regexlib.com/REDetails.aspx?regexp_id=930) US ZIP Code regex and John Alpha's (http://regexlib.com/REDetails.aspx?regexp_id=2754) Canadian Postal Code regex. It takes a Canadian postal code with or without a space and matches the first three digits to the named reference 'part1', the second three digits to the named reference 'part2', and the entire code (if a match) to the named reference 'full'
Matches
M4S 1G9 | M4S1G9 | K1A0B1 | K1A 0B1
Non-Matches
123 ABC | 5A2A2B | K1A 0B | M4S | 90210
Author Rating: The rating for this expression. Christopher Congdon
Title Test Details US ZIP codes with valid prefixes
Expression
(?!00[02-5]|099|213|269|34[358]|353|419|42[89]|51[789]|529|53[36]|552|5[67]8|5[78]9|621|6[348]2|6[46]3|659|69[4-9]|7[034]2|709|715|771|81[789]|8[3469]9|8[4568]8|8[6-9]6|8[68]7|9[02]9|987)\d{5}
Description
This matches all 5 digit numbers whose first three digits match valid US ZIP code prefixes.
Matches
10038 11205 20723
Non-Matches
09911 26942 98763
Author Rating: The rating for this expression. Brandon Schlueter
Title Test Details US (5 or 9 digits) Zip Codes with grouping
Expression
(?&lt;group5&gt;[0-9]{5})-?(?&lt;group4&gt;[0-9]{4})?
Description
Match 5-digit or 9-digit US zip codes with grouped results. Remember to replace &lt; with open tag char and &gt; with close tag char
Matches
12345 | 12345-6789 | 123456789
Non-Matches
12345 6789
Author Rating: Not yet rated. Vassilis Petroulias
Title Test Details US ZipCode
Expression
(^(?!0{5})(\d{5})(?!-?0{4})(|-\d{4})?$)
Description
This expression matches two different formats of zip codes: 5 digit US ZIP code and 5 digit US ZIP code + 4.The first one must be 5 numeric digits. The ZIP+4 must be 5 numeric digits, a hyphen, and then 4 numeric digits.
Matches
12345 | 12345-1234
Non-Matches
00000 | 123451234 | 12345-0000 | 00000-0000 | 00000-1234 | 000001234
Author Rating: The rating for this expression. megha patel
Title Test Details U.S. and Canadian postal codes
Expression
^((\d{5}-?\d{4})|(\d{5})|([A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d))$
Description
This expression more loosely 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 (optional), and then 4 numeric digits. The Canadian postal code must be of the form ANANAN where A is any alphabetic character (case insensitive) and N is a numeric digit from 0 to 9. A space between the 2nd "A" and 2nd "N" is optional but not required, so the form could also be interpreted as "ANA NAN"
Matches
90210, 90210-1234, 902101234, H0H0H0, h0h0h0, H0H 0H0, h0h 0h0
Non-Matches
9021090210, California, ABC123, ABC 123, H0H H0H
Author Rating: Not yet rated. Douglas Barbin
Title Test Details Matching US zip codes
Expression
^[0-9]{5}(-[0-9]{4})?$
Description
This expression will match 5 or 9 digit US zip codes
Matches
23654, 92456-1234
Non-Matches
236541, 222, 22, 1, 45-568845
Author Rating: Not yet rated. Mukundh
Title Test Details US zip codes with or without dashes
Expression
(^\d{5}$)|(^\d{9}$)|(^\d{5}-\d{4}$)
Description
Regex to allow only 9 digit zip code with or without dashes
Matches
32225-1234, 32225, 322251234
Non-Matches
asdfg
Author Rating: Not yet rated. Rennish Joseph
   Displaying page 1 of 1 pages; Items 1 to 15

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