mnooning has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex not matching special char
by kennethk (Abbot) on Dec 13, 2012 at 15:56 UTC | |
by mnooning (Beadle) on Dec 14, 2012 at 00:48 UTC | |
by AnomalousMonk (Archbishop) on Dec 14, 2012 at 05:43 UTC | |
by Anonymous Monk on Dec 14, 2012 at 08:50 UTC | |
by mnooning (Beadle) on Dec 14, 2012 at 12:33 UTC | |
by muba (Priest) on Dec 14, 2012 at 04:24 UTC | |
by mnooning (Beadle) on Dec 14, 2012 at 13:36 UTC |