re.escape()

re.escape(string) Escape all the characters in pattern except ASCII letters, numbers and '_'. This is useful if you want to match an arbitrary literal string that may have regular expression metacharacters in it. Changed in version 3.3: The '_' character is no longer escaped.

re.error.pos

pos The index of pattern where compilation failed.

re.error.pattern

pattern The regular expression pattern.

re.error.msg

msg The unformatted error message.

re.error.lineno

lineno The line corresponding to pos.

re.error.colno

colno The column corresponding to pos.

re.error

exception re.error(msg, pattern=None, pos=None) Exception raised when a string passed to one of the functions here is not a valid regular expression (for example, it might contain unmatched parentheses) or when some other error occurs during compilation or matching. It is never an error if a string contains no match for a pattern. The error instance has the following additional attributes: msg The unformatted error message. pattern The regular expression pattern. pos The index

re.compile()

re.compile(pattern, flags=0) Compile a regular expression pattern into a regular expression object, which can be used for matching using its match() and search() methods, described below. The expression’s behaviour can be modified by specifying a flags value. Values can be any of the following variables, combined using bitwise OR (the | operator). The sequence prog = re.compile(pattern) result = prog.match(string) is equivalent to result = re.match(pattern, string) but using re.compile() a

range.stop

stop The value of the stop parameter

range.step

step The value of the step parameter (or 1 if the parameter was not supplied)