[pcre-dev] Clarification on unused groups vs DEFINE

Top Page
Delete this message
Author: Jean-Christophe Deschamps
Date:  
To: pcre-dev
Subject: [pcre-dev] Clarification on unused groups vs DEFINE
I use a closed-source scripting language using PCRE inside wrapper
functions.

I observe a parasitic empty match for every DEFINE special condition.
I'd like to report the issue but before doing so I find it preferable
to make a more precise diagnosis.

How do we differentiate between an unused capturing group and a
pseudo-match resulting from a DEFINE?

For instance and in Perl format, the following patterns give me the
same result on input 'bbb' even when the DEFINE is not actually used:
/(a)? (b+)/x
/(?(DEFINE) (?<head> xyz)) (b+)/x

In both cases I get:
''     (an empty capture)
'bbb'


In the latter case I would expect only one captured group:
'bbb'
This is of course what I get when I remove definition of head.

So I'd like to point out how to prevent the bug in this particular
implementation, in order to simplify dev job. I suspect it has to do
with how ovector entries are interpreted but from the PCRE docs it
seems both empty group and DEFINE return (-1, -1) well, provided I read
the docs correctly.

Thank you for an outstanding product and support!