Search the Community
Showing results for tags 'postal'.
Found 1 result
I could use some help with a Regex pattern. I am attempting to extract some names and addresses (US format) from some free form text. Examples: Jane Doe PO Box 1234 Pensacola, FL 32524 Jane Doe 123 Sunset Blvd Apt 456 Pensacola, FL 32524 Jane Doe 555 Any Street Pensacola, FL 32524-1234 Second address line is optional. There are instances where the city or state may be missing. I came up with the following pattern through research / trial & error, but it isn't working exactly as I desire: (.+)(?>\r\n)(.+)(?>\r\n)(.+)(?>\r\n)?(.+)?,\h+(\w+)? ([-\d]+) When the second address line is missing, the value for city ends up in the wrong place. Suggestions on how I can fix / improve the pattern? TIA, Dan