Regular expression guaranteed to fail

Hallvard B Furuseth h.b.furuseth at usit.uio.no
Sun Aug 22 14:07:51 EDT 2004


Eric Brunel wrote:

> I also looked for a never-matching re just a few days ago and ended up
> with "^(?!$)$". It's certainly not more "standard" than yours, but I
> find it a wee tad more readable (for a regular expression, I mean...):

I think e.g. r'\Zx' and r'x\A' are more readable.  In particular the
latter, but perhaps that causes Python to locate every 'x' in the string
and then check if the string starts at the next character...

-- 
Hallvard



More information about the Python-list mailing list