Reputation: 9013
I have an array of strings:
"Turn <b>left</b> onto <b>Capitol Ave SW</b>"
"Head <b>east</b> toward <b>Browder St</b>"
"Merge onto <b>I-20 E</b><div style=\"font-size:0.9em\">Passing through Louisiana</div><div style=\"font-size:0.9em\">Entering Mississippi</div>" string
"Keep <b>right</b> at the fork to continue on <b>I-20 E</b>/<b>US 49 S</b>, follow signs for <b>Hattiesburg</b>/<b>Meridian</b><div style=\"font-size:0.9em\">Continue to follow I-20 E</div><div style=\"font-size:0.9em\">Entering Alabama</div>"
"Merge onto <b>I-20 E</b><div style=\"font-size:0.9em\">Passing through Georgia, South Carolina</div>"
I need to get substrings "Passing through X, Y" and "Entering Z". So, I need to get all states :)
UPDATED:
This pattern works:
Passing though [A-Za-z, ]+
https://www.regex101.com/r/FL2eyO/2
Upvotes: 1
Views: 30
Reputation: 785108
Translating my comment into an answer.
Following regex should work for you:
\b(?:Passing thr?ough|Entering) ([A-Za-z, ]+)
Problem was missing space before city name and no quantifier in your city name pattern.
Upvotes: 1