use v5.34;
$_ = "# name = 'epii1/tagbar-markdown'";
if(/name(?<!#\s{0,20})\s*=\s*'.*'/) {
print "$_\n";
}
I want to match strings which contain name = '.*' and are not commented.
For example, name = 'tpope/vim-scriptease' should be matched, and # name = 'epii1/tagbar-markdown' should not. I use a negative zero-width assertion, not positive. I know the right pattern should be (?<!#\s{0,20})name\s*=\s*'.*'. I just want to have a try and I think the pattern in the code block is wrong, and the given string would be matched. However, nothing is printed (except the warning about variable length lookbehind), so perl judges it is not matched.
Then I write in javascript:
let text = "# name = 'epii1/tagbar-markdown'";
let pattern = /name(?<!#\s{0,20})\s*=\s*'.*'/;
let result = pattern.test(text);
console.log(result);
result gives true.
So is this a bug of perl?