in reply to Regular Expressions and Question Marks

Try this
$matchtext = q(http://www.foo.bar/somepage.pl?); $substitutetext = "http://www.new.site/somenewpage\?"; s/\Q$matchtext\E/$substitutetext/;
Artist

Replies are listed 'Best First'.
Re: Re: Regular Expressions and Question Marks
by TGI (Parson) on Mar 14, 2002 at 00:05 UTC
    According to perlre:
    \E end case modification (think vi) \Q quote (disable) pattern metacharacters till \E

    Depending on what sort of text you want entered in $matchtext, this could be great or a disaster. Assuming that there were a few lines of code between the regex and the initialization,it would be pretty easy to forget that metacharacters are disabled. So if you take this route, make sure to leave a note for yourself where you set the variable. Running the wrong regex to diddle a bunch of files can ruin your day. (How good are your backups?)


    TGI says moo