I have a list of strings in which I want to filter for strings that contains keywords.
I want to do something like:
fruit = re.compile('apple', 'banana', 'peach', 'plum', 'pinepple', 'kiwi']
so I can then use re.search(fruit, list_of_strings) to get only the strings containing fruits, but I'm not sure how to use a list with re.compile. Any suggestions? (I'm not set on using re.compile, but I think regular expressions would be a good way to do this.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…