Is there a simple way to transform an exact string matching to a re.compile object ? For example, I would like to mix exact string and regexes.
1 Answer
You can probably use re.escape to escape everything in a string, and then use the escaped string as a pattern.
def transform(s):
return re.compile(re.escape(s))