I have a large string and a list of search strings and want to build a boolean list indicating whether or not each of the search strings exists in the large string. What is the
My version using regular expressions:
def check_strings(search_strings, input_string):
regexp = re.compile('|'.join([re.escape(x) for x in search_strings]))
found = set(regexp.findall(input_string))
return [x in found for x in search_strings]
On the test data provided by original poster it is by an order of magnitude slower than Rob's pretty solution, but I'm going to do some benchmarking on a bigger sample.