fork download
  1. import re
  2. p = re.compile(r'( of (?:(?!\band\b)[A-Za-z ])+)?')
  3. s = " of New Mexico and Mrs Smith."
  4. m = p.search(s)
  5. if m:
  6. print(m.group().strip())
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
of New Mexico