in reply to Regular expression match trouble with "+"
Your suspicions are correct. The + is a special character in regexps. You need to escape it. Here are two methods of doing it programatically:
if ($a =~ m/\Q$b\E/i)
$b = quotemeta($b); if ($a =~ m/$b/i)
References: perlre and quotemeta
Update: It's much faster to use string functions when dealing which constant strings. Case-insensitivity is obtained by converting both strings to a common case using lc or uc.
if (lc($a) eq lc($b))
|
|---|