Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2019-07-21 20:13
Flavor·PCRE (Legacy)

/
^(?:(?<numberstreet>\d+(?:\ +\w+)+(?=\n|\,))|(?<pobox>[P][.]?[O][.]?[\s|\-][B|b][O|o][X|x][\s]\d+(?=\n|\,)))?(?:\ *\,\ *)?(?<suite>(?:SUITE) [\#]?\d+)?(?:\ *\,\ *)?(?<citystatezip>(?<city>[^\,\s][\w\s]+)(?:\ *\,\ *)(?<stateabrv>[A-Z]{1,3})(?:\ +)(?<zipcode>\d{5}(?:\-\d*)?))?$
/
gmi
Open regex in editor

Description

Groups: street address (and suite if available), PO Box (if available), city, state (abbreviation) and zip code.

Submitted by anonymous