rurban / re-engine-PCRE2

use pcre-jit instead of slow perl regex
Other
1 stars 4 forks source link

Incorrect match results for /g pattern in modern perls #41

Open todd-richmond opened 1 year ago

todd-richmond commented 1 year ago

looping over multiple matches in a PCRE2 regex returns incorrect results. This simple test case shows the bug, and more complex ones I have return a single match instead of multiple matches. Standard perl regex and the RE2 engine work correctly Tested with perl 5.38 and 5.36

use strict;
#use utf8;
use warnings;

my $regstr = '\d{3}';
my $r1 = qr/$regstr/;
use re::engine::PCRE2;
my $r2 = qr/$regstr/;
use re::engine::RE2;
my $r3 = qr/$regstr/;
my $text = '123-45-6789 123-45-6789 123-45-6789';
#my @a = $text =~ m/$r2/g;

printf "string:\t%s\n", $text;
printf "pcre:\t%s\n", join (',', $text =~ m/$r1/g);
printf "pcre2:\t%s\n", join (',', $text =~ m/$r2/g);
printf "re2:\t%s\n", join (',', $text =~ m/$r3/g);

string: 123-45-6789 123-45-6789 123-45-6789 pcre: 123,678,123,678,123,678 pcre2: 123,45-,123,45- re2: 123,678,123,678,123,678