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.
BLA(?!.*?BLA.*?LOOK).*?LOOK
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…