1
我有一個字符串數組:正則表達式的一些模式將文字
"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>"
我需要得到子「通過X傳遞,Y」和「輸入Z」。 所以,我需要得到所有國家:)
更新:
這種模式的工作原理:
Passing though [A-Za-z, ]+
https://www.regex101.com/r/FL2eyO/2
嘗試:'雖然通過[A-ZA-Z,] +' – anubhava
@anubhava請寫一個答案,我可以+1它 –
如何說「,」(逗號和空格)應該是成對的? –