i think i found the problem, but it is mostly speculation since i don't have access to low-level PCRE implementations smile

in the PCRE doc and more plainly in the pcre demo code, the author checks for an empty match using:

Code:
if (ovector[0] == ovector[1])


this is not the correct way to check for an empty match, however, since ovector[0] (the reported starting position) can be completely distorted in both directions using \K.

the correct way, as far as i can see, would be to compare ovector[1] (the reported ending position) to the original value of start_offset, since this cannot be mutilated by the user. i'm going to file a report with PCRE's Philip Hazel and see what he has to say smile


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde