In this narrowed down regex case, each line produces an ERR.
I cannot spot the error. Can you?Just to be clear, the dollar sign could be one or more other special chars, not just a single dollar sign
my $line1 = 'I:\$AVG'; # Should NOT be okay. my $line2 = 'I:\$AVG\hello.log'; # Should NOT be okay. my $skip = '$AVG'; #------------------------------------------------ if ($line1 =~ m!\b\Q$skip\E\b!i) { print __LINE__." Line 1 Okay!\n"; } else { print __LINE__." Line 1 ERR! $line1 did not match $skip\n"; } if ($line2 =~ m!\b\Q$skip\E\b!i) { print __LINE__." Line 2 Okay!\n"; } else { print __LINE__." Line 2 ERR! $line2 did not match $skip\n"; } __END__ 14 Line 1 ERR! I:\$AVG did not match $AVG 19 Line 2 ERR! I:\$AVG\hello.log did not match $AVG
In reply to regex not matching special char by mnooning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |