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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^[ \w]{3,}([A-Za-z]\.)?([ \w]*\#\d+)?(\r\n| )[ \w]{3,},\x20[A-Za-z]{2}\x20\d{5}(-\d{4})?$
Description
This is a simple expression to check a US street address entered on either one or two lines. Being short it does not check that the road qualifer is "valid" (eg. drive, avenue, etc), but it does allow for the extended zip code. A word of warning, the multiline mode can be picky about ending the first line with extra space.
Matches
123 Anywhere Dr. apt #99 Somewhere, ST 55789 | 123 Anywhere Dr. Somewhere, ST 55789 | 123 Anywhere D
Non-Matches
123 Anywhere Drive #99 Somewhere, ST 55789 - 1234 | 123 Anywhere Dr. apt. #99 Somewhere, ST 55789 |
Author Rating: The rating for this expression. Gideon Engelberth
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

Title: Pattern Changes
Name: Ty Whalin
Date: 8/26/2014 3:49:28 PM
Comment:
I changed the regular expression to allow a few different options. I like what you created here, but wanted to change the pattern to only allow for the capitol letters with an ending period after the state. I also thought it would be nice to allow the expression to show the possible option of direction with for example North, South, East or West with an ending period at the end of it. ^[ \w\.]{3,}([A-Za-z]\.)?([ \w]*\##\d+)?(\r\n| )[ \w]{3,},\x20([A-Z]{2}\.)\x20\d{5}(-\d{4})?$ Although the code was not altered much, it reflects the changes I find necessary for my needs.


Title: Pattern Changes
Name: Ty Whalin
Date: 8/26/2014 3:49:21 PM
Comment:
I changed the regular expression to allow a few different options. I like what you created here, but wanted to change the pattern to only allow for the capitol letters with an ending period after the state. I also thought it would be nice to allow the expression to show the possible option of direction with for example North, South, East or West with an ending period at the end of it. ^[ \w\.]{3,}([A-Za-z]\.)?([ \w]*\##\d+)?(\r\n| )[ \w]{3,},\x20([A-Z]{2}\.)\x20\d{5}(-\d{4})?$ Although the code was not altered much, it reflects the changes I find necessary for my needs.


Title: Pattern Changes
Name: Ty Whalin
Date: 8/26/2014 3:49:00 PM
Comment:
I changed the regular expression to allow a few different options. I like what you created here, but wanted to change the pattern to only allow for the capitol letters with an ending period after the state. I also thought it would be nice to allow the expression to show the possible option of direction with for example North, South, East or West with an ending period at the end of it. ^[ \w\.]{3,}([A-Za-z]\.)?([ \w]*\##\d+)?(\r\n| )[ \w]{3,},\x20([A-Z]{2}\.)\x20\d{5}(-\d{4})?$ Although the code was not altered much, it reflects the changes I find necessary for my needs.


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