fork download
  1. import re
  2.  
  3. regex = r"(?<=\bABC\s)(?!.*\bABC\b).*"
  4.  
  5. s = ("ABC anything about the sky ABC and anything about the moon\n"
  6. "ABC anything about the sky ABC and anything ABC about the moon")
  7.  
  8. print(re.findall(regex, s))
Success #stdin #stdout 0.02s 9624KB
stdin
Standard input is empty
stdout
['and anything about the moon', 'about the moon']