[Solved] regex multiple string match in a python list


Here’s a solution using regex if that’s what you really need. I search to see if any of your 3 substrings are present inside any given string from the list. Using https://docs.python.org/3/library/re.html as the Python regex library.

import re
for word in wordList:
  m = re.search('.*(ra|dec|lat).*', word)
  if m:
    <youve matched here>

solved regex multiple string match in a python list