From answer of @skyfoot at this question regex-lookahead-lookbehind-and-atomic-groups
He said that:
given the string `foobarbarfoo`
bar(?=bar) finds the first bar.
bar(?!bar) finds the second bar.
(?<=foo)bar finds the first bar.
(?<!foo)bar finds the second bar.
you can also combine them
(?<=foo)bar(?=bar) finds the first bar.
What's happened suppose i have string "barfoobarbarfoo
"
And i want to find these bold text
"barfoobarbarfoo"
The regex might be: (?<=bar)foo(????)bar(?=foo)
The question is that what expression should be in the middle (look ahead
or look behide
)?