Read up on the function quotemeta.
Alternatively, wrap it with \Q$regexp\E in your regexp like this:
my $text = 'foo bar + \wbaz'; my $re = ' + \w'; if ($text =~ /(\Q$re\E)/) { print $1; } else { warn "nothing found\n"; }
That goes for the same as quotemeta does, just for the regexp.
Mats
In reply to Re: regex special chars
by matsmats
in thread regex special chars
by rsiedl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |