[Python-ideas] PEP 8: raw strings & regular expressions

Serhiy Storchaka storchaka at gmail.com
Tue Oct 27 04:33:12 EDT 2015


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)').




More information about the Python-ideas mailing list