Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
todd-richmond opened this issue Sep 27, 2023 · 0 comments
Open

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

todd-richmond opened this issue Sep 27, 2023 · 0 comments
Assignees
Labels

Comments

@todd-richmond
Copy link

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

@rurban rurban self-assigned this Sep 27, 2023
@rurban rurban added the bug label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants