
Andrew Barnert via Python-ideas <python-ideas@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