0
s = "These are roses and lilies and orchids, but not marigolds or .."
r = re.compile(r'\roses\b | \bmarigolds\b | \borchids\b', flags=re.I | re.X)
print(r.findall(s))

Is it possible to add variables to the re.compile words?

keyword1 = 'roses'
keyword2 = 'marigolds'
keyword3 = 'orchids'
joelcloud
  • 27
  • 5

0 Answers0