Reputation: 104
I have a list of address such as the following:
Find Dabla Inc at 6889 66th Ave, NY, NY 11884-3773. Call them at (888) 292-1655.
Find Walgreen Drug Stores at 6008 87th Ave, NY, NY 17774-4314. Call them at (888) 999-473
Find Silver Star Restaurant at 6941 99th Ave Ste A, NY, NY 88804-2915. Call them at (888) 851-2799.
I am trying to extract the street address, state, city and zip code from this text via Regex.
Currently, I am using the following to match street address:
(?<=at\s)\d{3,5}\s\S*\s\w*.*(?=,)
However, I see it inlcudes in match NY, instead of stopping after the first comma (it only stops after second comma).. Why is it including first comma if I'm using a positive lookahead?
Thannks
Upvotes: 1
Views: 53
Reputation: 67998
(?<=at\s)\d{3,5}\s\S*\s\w*.*?(?=,)
^^
Make your regex non greedy
.
See demo: https://regex101.com/r/fX3oF6/14
Upvotes: 3