Bilbo has asked for the wisdom of the Perl Monks concerning the following question:
in which $pattern could contain characters with special regexp meanings is there a way to make this work "sensibly" without using one or more previous regexps to escape all the special characters (ie in this case convert $pattern to '\$ signs').my $string = 'Some text with $ signs in it'; my $pattern = '$ signs'; $string =~ s/$pattern/dollar signs/; print "$string\n"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quoting strings in regexps
by japhy (Canon) on Jul 19, 2002 at 19:07 UTC |