booleans = [boolean_and_new(terms) for terms in [['sweet pie',
    'savoury pie', 'meringue'], ['chicken pie', 'beef pie']]]
regex1 = re.compile('(?i)\\b(?:%s)\\b' % '|'.join(words_and_phrases))
regex2 = re.compile('(?i)%s' % '|'.join(booleans))
matched_data = list()
for d in data():
    if regex1.search(d) or regex2.match(d):
        matched_data.append(d)
What is the fastest way in Python to find if a string matches any terms in a list of words, phrases, boolean ANDs?