perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

(*SKIP) skips when \b should match

Open rsFalse opened this issue 1 year ago • 1 comments
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

rsFalse avatar Dec 30 '23 17:12 rsFalse

FYI behaviour unchanged since 5.18 up until current blead.

leonerd avatar Mar 14 '24 17:03 leonerd