RegEx模式匹配单词的第n个和第m个出现

时间:2013-08-31 03:11:30

标签: regex

我有一些示例字符串,如:

There is one wherever you one and here is the one , nowhere is the one .

我想在第二个one和第三个one之间进行提取,即and here is the

我不确定如何相应地定位我的模式..任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

\K非常不受欢迎

grep -oP '^(.*?one){2}\K.*?(?=one)' \
     <<< "There is one wherever you one and here is the one , nowhere is the one"
and here is the