I am trying to find the occurrence of various terms that are not preceded by another group of terms. Normally if I would have a single term in the preceding group I could use a negative lookbehind, but at Python has a zero-width assumption this doesn't seem to be the case. The only solution I see is to run two regexes, one for the presence of what I am looking for and another to confirm the non-existence of the preceding group terms. There must be a more elegant and efficient way of doing this. Can anyone help?
The test sentence is:
10 day trip excludes flights
The regex that assures that it isn't matched due to the word 'flights' being preceded by 'excludes' is the following:
(?:without|not including|doesn\'?t include|exclud(?:es|ing))\s*(?:flights?(?:\s+tickets)?|airfare|airline tickets?)
However I want to assure that certain text is included. I can confirm this with the following:
(?:flights?(?:\s+tickets)?|airfare|airline tickets?)
So this would match 'including ticket' and 'and airfare' but not 'without flight tickets'
Some examples of matching strings are:
including flights
includes flights
plus flights
flights are included
including airfare
and airfare
Some examples of non-matching strings are:
not including flights
flights are not included
excluding flights
without airfare