Assume the following word sequence
BLA text text text text text text BLA text text text text LOOK text text text BLA text text BLA
What I would like to do is to extract the text from BLA to LOOK, but the BLA which is the closest to look. I.e. I would like to get
BLA text text text text LOOK
How should I do that using regular expressions? I got one solution which works, but which is exteremely inefficient.
Is there a better and more performant way to achieve matching this pattern?
What I would like to do is: I would like to match BLA, then forward lookahead until either positive fordward lookahead with LOOK or negative lookahead with BLA. But I don’t know a way to put this into a regular expression.
As a engine I use re in python.
Try this.See demo.
To be safer.