Lets say I have a list of strings,
string_lst = [\'fun\', \'dum\', \'sun\', \'gum\']
I want to make a regular expression, where at a point
Except for the regular expression, you can use list comprehension, hope it's not off the topic.
import re
def match(input_string, string_list):
words = re.findall(r'\w+', input_string)
return [word for word in words if word in string_list]
>>> string_lst = ['fun', 'dum', 'sun', 'gum']
>>> match("I love to have fun.", string_lst)
['fun']