Regex 在字符之间的任意位置匹配特定字符串
我不想把两个角色之间的所有东西都匹配起来,就像在。我在寻找一个特定的短语。例如:Regex 在字符之间的任意位置匹配特定字符串,regex,Regex,我不想把两个角色之间的所有东西都匹配起来,就像在。我在寻找一个特定的短语。例如: cat {mouse ostrich dog ostrich} fish {ostrich} ostrich 我想匹配花括号中的三根“鸵鸟”弦,但不想匹配其他任何东西。这可能吗?如果您的引擎支持\G(PCRE…),您可以很好地与 (?:\G(?!\A)|{) # match the start of the last match or { [^{}]*?\K # not { or } lazily, \
cat {mouse ostrich dog ostrich} fish {ostrich} ostrich
我想匹配花括号中的三根“鸵鸟”弦,但不想匹配其他任何东西。这可能吗?如果您的引擎支持
\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
请参阅。请说明您迄今为止所做的工作以及失败的地方。