[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch for lookaround assertion in regexp

From: Stefan Monnier
Subject: Re: Patch for lookaround assertion in regexp
Date: Tue, 24 Jan 2012 12:34:58 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

>>> As an alternative to PCRE, which, as has already been pointed out,
>>> doesn’t match any of these requirements, how about RE2?
>>> http://code.google.com/p/re2/
>>> It’s written in C++, which is a minus, but it should be simple enough
>>> to extend it with \c and \s.
>> That might work, indeed (tho someone still has to write the
>> corresponding code).
>> Note that it does not support lookaround assertions.
> True, but you can, as far as I know, not do so without (allowing for)
> exponential behavior.

Actually, no.  Contrary to backreferences (which are outside of the
mathematical notion of regular expressions, and can't be matched in
linear time), lookahead assertions are "normal".  So RE2 may get support
for lookahead assertions in the future (maybe for lookbehind as well,
tho that's more difficult).

> I don’t want to detract from the merits of lookaround assertions (or
> start a discussion on the subject), but I’ve always found them to be a
> sign of improper use of (no longer) regular expressions.

I just pointed it out as supporting my argument that I'd rather not add
lookaround assertions since it may make it more difficult to change to
an linear-time matcher later on.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]