fork download
  1. import re
  2.  
  3. regex = r"\b(?:MS|PhD)\s*((?:(?!\b(?:MS|PhD)\b).)*)[.,]"
  4. s = ("Candidate with MS or PhD in Statistics, Computer Science, or similar field.\n"
  5. "Applicant with MS in Biology or Chemistry desired.")
  6.  
  7. matches = re.findall(regex, s)
  8. print(matches)
Success #stdin #stdout 0.02s 9544KB
stdin
Standard input is empty
stdout
['in Statistics, Computer Science, or similar field', 'in Biology or Chemistry desired']