2017-09-23 109 views
-1

我不是想匹配一切两个字符之间,如this question。我正在寻找匹配一个特定的短语。例如:匹配特定字符串之间的任何字符

cat {mouse ostrich dog ostrich} fish {ostrich} ostrich 

我想匹配大括号中的三个'鸵鸟'字符串,但没有其他任何东西。那可能吗?

+0

请说明你迄今为止做了什么以及哪里出了问题。 – Binarus

回答

-1

如果你的引擎支持\G(PCRE ......),你很可能与

(?:\G(?!\A)|{) # match the start of the last match or { 
[^{}]*?\K  # not { or } lazily, \K "forgets" the match thus far 
ostrich  # ostrich literally 

a demo on regex101.com相处。

相关问题