def normalize(string, pattern=False, preserve_case=False):
regex = re.compile(r'<STR_LIT>') if pattern else re.compile(r'<STR_LIT>')<EOL>if not isinstance(string, string_types):<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>string = string.strip() if preserve_case else string.strip().casefold()<EOL><DEDENT>except AttributeError:<EOL><INDENT>string = string.strip() if preserve_case else string.strip().lower()<EOL><DEDENT>return regex.sub('<STR_LIT>', string)<EOL>
Normalize input for comparison with other input
:param string: The string to normalize
:type  string: str

:param pattern: Allow wildcard symbols for triggers
:type  pattern: bool

:param preserve_case: Normalize the message without casefolding
:type  preserve_case: bool

:rtype: str