
Oct. 27, 2015
8:33 a.m.
On 27.10.15 04:26, Chris Angelico wrote:
Fortunately, it's easy to write a function that validates a regex.
def is_regex(s): try: re.compile(s) except re.error: return False return True
re.compile() also can raise OverflowError ('.{,9999999999}') and ValueError ('(?ua)').