City State Zip Regex

Regular Expression that splits the last line in an address into it's funtional parts.

^(? [A-Za-z\s]*)(?:,\s?(? [\sA-Za-z]+)|\s(? [A-Za-z]{2})) (?: (?:\d{1,4})| (? \d{5})(?:-\d{0,3})| (? \s\d{5})-(? \d{4})| (? \s\d{5})| (?\s[AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d)| )$

This regular expression will return the following elements of an address:


 * City
 * State/Province (called State in the return)
 * Zip
 * Zip4 - The Zip4 part of the zipcode.
 * PC - This is the Postal Code for Canadian Addresses.