[Python-ideas] PEP 8: raw strings & regular expressions
David Mertz
mertz at gnosis.cx
Mon Oct 26 17:53:48 EDT 2015
Obviously there can't be a regex to exclude everything that isn't a regex.
Parentheses can nest to unlimited depths, so you need a formal grammar. But
virtually everything that is a Windows path is also formally grammatical
regex too (as are many things with no plausible likely intention as such)
On Oct 26, 2015 2:44 PM, "Ben Finney" <ben+python at benfinney.id.au> wrote:
> 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
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151026/3a776358/attachment.html>
More information about the Python-ideas
mailing list