regex street address match

US addresses are not a regular language, and cannot be matched by using regular expressions. They are helpful in some isolated cases, but in general, they will fail you, especially for input like that.

I used to work at an address verification company. In answer to your question, to “highlight an address” in a string of text, I recommend you try an extraction utility. There are a few out there and I suggest you look around, but here is ours using the input from your question — as you can see, it found the address and validated it:

LiveAddress extraction example

The API endpoint returns JSON which contains the start and end positions of each address, as well as plenty of information about each one. (See the CSV output at the bottom of the picture above.)

I commend you for braving those regular expressions you tried! Hopefully this is helpful.

Leave a Comment