in reply to Another (maybe stupid) regex question ...
You need to escape the relevant characters - luckily you don't have to roll your own escaper, just use \Q and \E -
$text2 =~ s/(\Q$text1\E)/FOO$1BAR/;
BTW you describe one thing (replace small text), but then do another (put FOO and BAR on either side of small text) - did you mean /FOOBAR/ or /FOO$1BAR/?
ABTW I'm not convinced there are any stupid questions, just stupid answers (plus a lot of inquisitive idiots ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
[OT] "stupid" questions (was Re: Another (maybe stupid) regex question ...)
by jonadab (Parson) on Nov 18, 2003 at 01:09 UTC | |
by Melly (Chaplain) on Nov 18, 2003 at 12:39 UTC |