in reply to Re: Seeking clarification on possible bug in regex using \G and /gc
in thread Seeking clarification on possible bug in regex using \G and /gc

The closest mention I could see to this problem and perhaps a clue is: The additional state of being matched with zero-length is associated with the matched string, and is reset by each assignment to "pos()". So perhaps the issue is that the previous match succeeded - but did not advance pos, so when the /\G \z/ hits, pos doesn't advance and for some reason perl doesn't treat it as a successful match. I'm still with davido. I think this is a bit of a bug - it introduces failure at a distance in custom parsing engines. Luckily for cases such as these pos == length happens to be true.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
  • Comment on Re^2: Seeking clarification on possible bug in regex using \G and /gc

Replies are listed 'Best First'.
Re^3: Seeking clarification on possible bug in regex using \G and /gc
by Anonymous Monk on Mar 15, 2018 at 18:54 UTC

    The opposite would be worse. If it didn't work like this, subtle differences would be introduced when you refactor some code, merging regexen or splitting them apart.