希望 match 到某几个特定单词的所有首次出现,比如下面这段文字(随便 copy 来的):
Mr. Obama also used his own remarks to try to drive a wedge between Mr. Trump’ s campaign and Republican voters. “ It wasn ’ t particularly Republican and it sure wasn ’ t conservative,” he said of last week ’ s Republican convention. “ There were no serious solutions to pressing problems. Just the fanning of resentments and blame and hate and anger.” The president ’ s contempt for Mr. Trump took on a personal dimension as well when he recalled his grandparents from Kansas and said, “ I don ’ t know if they had their birth certificates ” — a reference to Mr. Trump’ s leadership of the so-called birther movement that raised questions about Mr. Obama’ s citizenship.
正则 (Obama|Trump)
会匹配到所有的 Obama 和 Trump (粗体的),现在希望仅匹配首次出现,即粗斜体的两个,研究了半天 lookbehind/back reference 啥的也没试出怎么写,求指导。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.