[Top][All Lists]

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

Re: Numbered regexps throw invalid regex error

From: Tom
Subject: Re: Numbered regexps throw invalid regex error
Date: Wed, 25 Jan 2012 17:51:43 +0000 (UTC)
User-agent: Loom/3.14 (

Andreas Röhler <andreas.roehler <at>> writes:

> Am 25.01.2012 11:17, schrieb Tom:
> >   (looking-at "\\(a\\(?1:b\\)\\)")
> >
> AFAIU there are serveral errors,
> think you can't refer to first match inside itself

You misunderstand the feature.

It's not a backreference. It's an explicit numbering of 
the group, so it doesn't change if you add more parens:

`\(?NUM: ... \)'
     is the "explicitly numbered group" construct.  Normal groups get
     their number implicitly, based on their position, which can be
     inconvenient.  This construct allows you to force a particular
     group number.  There is no particular restriction on the numbering,
     e.g. you can have several groups with the same number in which case
     the last one to match (i.e. the rightmost match) will win.
     Implicitly numbered groups always get the smallest integer larger
     than the one of any previous group.

reply via email to

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