I am working on a regex to parse full addresses by street number, street name, city, state, and zip code.
I came up with a pretty good regex that works for most cases, however, there are a couple scenarios where it fails. I need help with improving it. Here is what I have currently
Pattern pattern = Pattern.compile("^([\\d-]{0,}[\\s-]{0,}[\\d/]+)[\\s]{0,}");
This works fine if the street addresses are formed nicely where the address starts with a street number that has no letters attached to it. For example :
123 Street Address, CA, 55555
works fine.However
123 4th Street Address, CA, 55555
will result in :1234 => street number th Street => street name
I have done a lot of research on parsing addresses and this solution I have come up with is just about the simplest solution I've found. Just need a little more tweaks. Thanks in advance.