in reply to Quickie Question: search and replace problem
Basically, $data is intepreted as a string, and $attempt1 as a regex, so if you have special regex characters, they will never match up, no matter how you escape them.
To make a regex treat $attempt1 as a string, use \Q and \E:
Updated: Added rant, as per tye :)
To make a regex treat $attempt1 as a string, use \Q and \E:
man perlre for more info.$data =~ s/\Q$attempt1\E/$newstr/
Updated: Added rant, as per tye :)
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re: Quickie Question: search and replace problem
by tye (Sage) on Apr 19, 2001 at 00:58 UTC | |
by indigo (Scribe) on Apr 19, 2001 at 01:13 UTC | |
Re: Re: Quickie Question: search and replace problem
by JojoLinkyBob (Scribe) on Apr 19, 2001 at 00:55 UTC |
In Section
Seekers of Perl Wisdom