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

Ben Finney ben+python at benfinney.id.au
Mon Oct 26 17:44:12 EDT 2015


Andrew Barnert via Python-ideas
<python-ideas at python.org> writes:

> Just for fun: is there a Python regex that matches all valid Python
> regexes?

Yes: ‘.*’ matches all valid Python regexes.

> Obviously there's no actual regular expression that matches all
> regular expressions (you can't handle matched brackets without
> recursion or some other extension).

You seem to be seeking something else: a pattern that matches all valid
regex patterns, *and* will never match any string that is not a valid
regex pattern. The latter is rather more difficult.

-- 
 \      “When I was born I was so surprised I couldn't talk for a year |
  `\                                        and a half.” —Gracie Allen |
_o__)                                                                  |
Ben Finney



More information about the Python-ideas mailing list