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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Validate US Address Format
Expression
^(?<line1>(?!\s+)[^\n]+)\n(?:(?<line2>(?!\s+)[^\n]+)\n)?(?<city>[^,\n]+), +(?<state>-i:A[LKSZRAEP]|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]) +(?<zip>(?<zip5>\d{5})(?:[ -]?(?<zip4>\d{4}))?)$
Description
Validates the format of a US mailing address that includes a maximum of three lines. line1 (cannot be whitespace) line2 (optional; if present, cannot be whitespace) city, ST 00000-0000 (hyphen and last four digits of zip are optional) Captures line1, line2 (if present), city, state, and zip to groups similarly named for further processing.
Matches
Cannot enter multi-line example, you'll just have to try it
Non-Matches
101 South Park Drive
Author Rating: Not yet rated. Jerry Schmersahl
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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