python’s re: return True if string contains regex pattern November 21, 2022 by Tarik import re word = 'fubar' regexp = re.compile(r'ba[rzd]') if regexp.search(word): print('matched')