Try the following:
(?<=foo_bar_).*(?=_\d)
In this option, it includes the result of ALL ( .* ) Between foo_bar_ and _"any digit" .
In your regular expression, it includes the result:
foo_
He then searches for "bar" after "foo _":
(?=bar)
But at this stage it is not turned on. It is included in the next step:
bar_
And then the rest of the line is included (.*?)_\d+ .
So, in general: it includes in the result all of this that you typed, EXCEPT (? = Bar), which simply searches for "bar" after the expression.
source share