emacs-devel
[Top][All Lists]
Advanced

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

Re: Fixing ill-conditioned regular expressions. Proof of concept.


From: Alan Mackenzie
Subject: Re: Fixing ill-conditioned regular expressions. Proof of concept.
Date: Thu, 26 Feb 2015 10:11:37 +0000
User-agent: Mutt/1.5.22 (2013-10-16)

Hello, Paul.

On Thu, Feb 26, 2015 at 12:46:58AM -0800, Paul Eggert wrote:
> Alan Mackenzie wrote:
> > More to the point, it is sometimes
> > not possible to preserve the numbering of \(...\) constructs while
> > fixing a regexp, which would change the match-data.

> Sure, but you could remember how the \(...\) constructs were
> renumbered, and fix the match data after the underlying regexp call
> returned.  It shouldn't be a big deal.

Unfortunately, it's not that simple.  Consider the RE

    \(R\)+E*\(R\)+
     1  1    2  2

.  This gets transformed to

    \(R\)+\(?:E+\(R\)+\|\(R\)\)
     1  1        2  2    2  2

.  What was subexpression 2 in the original has become two subexpressions
straddling an \| sign in the transformation.  I don't think there's a way
of transforming R+E*R+ that preserves the numbering of the
subexpressions.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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