Suppose the following sequence of words
BLA text text text text text text BLA text text text text LOOK text text text BLA text text BLA
I would like to do to extract the text from the BLA in the LOOK, but the BLA that is closest to viewing. That is, I would like to receive
BLA text text text text LOOK
How can I do this with regular expressions? I have one solution that works, but which is extremely inefficient.
BLA(?!.*?BLA.*?LOOK).*?LOOK
Is there a better and more efficient way to match this pattern?
What I would like to do is: I would match the BLA and then go into lookahead until a positive reverse expression with LOOK or a negative look with BLA appears. But I do not know how to make this a regular expression.
As an engine, I use re in python.
source share