[pcre-dev] [Bug 1447] Support for Enumerations

Pàgina inicial
Delete this message
Autor: Philip Hazel
Data:  
A: pcre-dev
Assumpte: [pcre-dev] [Bug 1447] Support for Enumerations
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1447




--- Comment #3 from Philip Hazel <ph10@???> 2014-02-21 17:22:21 ---
On Fri, 21 Feb 2014, quetantofaz@??? wrote:

> Yet the use case is so common, take for example:
>
> (?@ ("[^"]*") | (\d+) | (\w+) )
>
> which would, when applied to an identifier 'abc' result in f.e.:
>
> "abc", 2, "abc"
>
> and not the current
>
> "abc", "", "", "abc"


In the case of a regex with many, possibly overlapping, matching
captures, I can't see how your interface makes things less complicated.
Certainly in your example above, if you just want to know "what did this
pattern capture?" you could either wrap the whole thing in ONE capturing
parens:

( (?: "[^"]*" | \d+ | \w+ ) )

or use repeated capture numbers:

(?| ("[^"]*") | (\d+) | (\w+) )

In both cases, what is captured appears as capture string 1.

> BTW, I saw that the syntax I used is already in use, I hadn't remembered it.


Do you mean (?@ ? I don't think this is in use in PCRE or Perl. At
least, it's not mentioned in the man pages.

Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email