I want to extract substring between apple
and each
in a string. However, if each
is followed by box
, I want the result be an empty string.
In details, it means:
1)apple costs 5 dollars each
-> costs 5 dollars
2)apple costs 5 dollars each box
-> ``
I tried re.findall('(?<=apple)(.*?)(?=each)'))
.
It can tackle 1) but not 2).
How to solve the problem?
Thanks.