$string =~ s/(?<!Y)(?<!^)X//g;
my $rstr = reverse $string; $rstr =~ s/X(?!Y|\Z)//g; # note \Z, not $ $string = reverse $rstr;
# old: # $string =~ s/([^Y])X/$1/g; # new: $string =~ s/[^Y]\KX//;
In reply to Re: Variable-width negative lookbehind
by japhy
in thread Variable-width negative lookbehind
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |