Created
January 20, 2015 21:42
-
-
Save aristretto/64d5bbac5897cdaff248 to your computer and use it in GitHub Desktop.
Useful way to search a given string for any of a list of terms, in python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def has_search_term(string_to_search): | |
patterns = re.compile(r'(?:%s)' % '|'.join(list_of_terms)) | |
return bool(patterns.search(string_to_search)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment