in reply to Re: Pattern matching fails because of special characters
in thread Pattern matching fails because of special characters
You can't escape with backslashes inside a character class.
Put the minus at the end and drop all backslashes, unless you want to match \ .
A counterexample:
(But I agree that putting the - at the end and dropping the backslashes would have the same effect.)c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'abc\ZD+A-G\HJxyz'; print qq{'$s'}; ;; $s =~ m{ ([A\-Z\+GD]+) }xms; print qq{'$1'}; " 'abc\ZD+A-G\HJxyz' 'ZD+A-G'
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Pattern matching fails because of special characters
by LanX (Saint) on Jun 10, 2019 at 01:25 UTC |