regex puzzle

Alexander Schmolck a.schmolck at gmx.net
Wed Nov 6 09:50:51 EST 2002


"Mike Brown" <mike at skew.org> writes:

> I need an example of a regular expression that:
> 
> - matches an empty string
> - matches a non-empty string
> - does NOT match a string consisting of only a linefeed

Try ``re.match('(?!\n)', s)`` (unless of course you can do if s != '\n').

alex



More information about the Python-list mailing list