import re pattern = r"\bJane(?:'?s|\(s\))? car\b|\b(car)\b" s = ("for example\n" " the car is red - Match\n" " here is Jane car is red -> None\n" " here is Janes car is red -> None\n" " here is Jane's car is red -> None\n\n" "2. I also want to find the cases Jane is in the phrase\n" " the car is red - None\n" " here is Jane car is red - Match\n" " here is Janes car is red - Match\n" " here is Jane's car is red - Match\n\n" "3. and where car is not preceding by Jane(s)\n" " here Jane(s) car is red - None\n\n" "4. and of course the opposite\n" " here is Jane(s) car is red - Match") result = [m for m in re.findall(pattern, s) if m] print(result)