perl5
perl5 copied to clipboard
(*SKIP) skips when \b should match
trafficstars
Description
(*SKIP) seems skipping new matching attempt if it starts with \b\w (word boundary) right after \W. Maybe because the last evaluated character was \w?
Steps to Reproduce
The only difference between two cases is \b in the beginning of regex.
#!/usr/bin/perl -w
use strict;
my $A = join ',', 1 .. 3, 'abc', 'zz';
print qq{A:"$A"\n};
$A =~ m/
\b(\w+)\b,(*SKIP)
\b(\w+)\b
(?{ print "[$1-$2]" })
(*FAIL)
/x;
print "\n";
$A =~ m/
(\w+)\b,(*SKIP)
\b(\w+)\b
(?{ print "[$1-$2]" })
(*FAIL)
/x;
print "\n";
OUTPUT:
A:"1,2,3,abc,zz"
[1-2][3-abc]
[1-2][2-3][3-abc][abc-zz]
Expected behavior
In the first case (*SKIP) shouldn't skip matching and output should be the same as in case 2.
Perl configuration
This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux
FYI behaviour unchanged since 5.18 up until current blead.