re.compile(ur"(?<=,| |^)(?:next to|near|beside|opp).+?(?=,|$)", re.IGNORECASE)
sre_constants.error: look-behind requires fixed-width pattern
error in my program but regex101 shows it to be fine.
What I'm trying to do here is to match landmarks from addresses (each address is in a separate string) like:
- "Opp foobar, foocity" --> Must match "Opp foobar"
- "Fooplace, near barplace, barcity" --> Must match "near barplace"
- "Fooplace, Shoppers Stop, foocity"--> Must match nothing
- "Fooplace, opp barplace"--> Must match "opp barplace"
The lookbehind is to avoid matching words with
opp in them (like in string 3).
Why is that error thrown? Is there an alternative to what I'm looking for?