How to capture an exception raised by a Python Regular expression?

PythonServer Side ProgrammingProgramming

When the match method is implemented, if it turns out that there are no matches, then None is returned. There are no functions in the re module that throw up an exception when the list or matches is empty

exception re.error

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.

raja
Published on 11-Jan-2018 10:54:25
Advertisements