[pcre-dev] [Bug 2756] Documented DFA example does not work a…

Top Page
Delete this message
Author: admin
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 2756] Documented DFA example does not work as expected
https://bugs.exim.org/show_bug.cgi?id=2756

Philip Hazel <Philip.Hazel@???> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED


--- Comment #1 from Philip Hazel <Philip.Hazel@???> ---
This is not a bug, but a misunderstanding. You used
match_data_create_from_code() to set up a match data block. As your pattern
contains no capturing parentheses, this will create a block with a very small
ovector (enough to hold just the whole match, no captured groups). However,
when you use the DFA matcher, the ovector is used in a different way, as
explained in the pcre2api page:

"On success, the yield of the function is a number greater than zero, which is 
the number of matched substrings. The offsets of the substrings are returned in
the ovector, and can be extracted by number in the same way as for           
\fBpcre2_match()\fP, but the numbers bear no relation to any capture groups  
that may exist in the pattern, because DFA matching does not support
capturing."


As your example should yield 3 matches, the ovector is not big enough, and
therefore the yield is zero. If you change the match data creation to create a
match data block with at least 3 ovector pairs, your example should return 3.

--
You are receiving this mail because:
You are on the CC list for the bug.