I'm trying to create a regular expression to match the following types of us locations:
486 S SOANGETAHA RD APT 9 GALESBURG IL
450 N CHERRY ST GALESBURG IL 61401
950 REDWOOD SHORES PKWY UNIT K102 REDWOOD CITY CA
123 MAIN ST
123 MAIN ST SAN FRANCISCO
MAIN ST & KELLOGG ST
EMBARCADERO ST & MARKET ST SAN FRANCISCO
These locations are in a long string with that varies in length.
This is the regular expression I'm using but it is also matching other strings that are not a location.
$STATE="(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[sY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])";
$STREET="(AVE|AVENUE|BLVD|BOULEVARD|CIR|CIRCLE|CT|COURT|EXPY|EXPRESSWAY|FWY|FREEWAY|LN|LANE|PKY|PKWY|PARKWAY|RD|ROAD|SQ|SQUARE|ST|STREET|TPKE|TURNPIKE)";
$DIREC="(N|NORTH|E|EAST|S|SOUTH|W|WEST|NE|NORTHEAST|SE|SOUTHEAST|SW|SOUTHWEST|NW|NORTHWEST)";
$NAME="(([A-Z]{3,15})( +([A-Z]{3,15})){0,1}( +([A-Z]{3,15})){0,1})";
$DESIG="(APARTMENT|APT|BUILDING|BLDG||FLOOR|FL|SUITE|STE|UNIT|ROOM|RM|DEPARTMENT|DEPT)";
$NUM="([0-9]{1,6})";
$APT="([A-Z0-9]{1,6})";
$ZIP="([0-9]{5})";
$USAddressPtn = "($NUM{0,1} *$DIREC{0,1} *$NAME{1} *$STREET{1} *$DESIG{0,1} *$APT{0,1} *$NAME{0,1} *$STATE{0,1} *$ZIP{0,1})";