in reply to safe regex variables

You want quotemeta() or \Q...\E:
$safe = quotemeta $unsafe; $text =~ /$safe/; # or $text =~ /\Q$unsafe\E/;


japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re: Re: safe regex variables
by oconnelm (Initiate) on Jul 06, 2001 at 02:46 UTC
    Aha! Exactly what I needed but couldn't find. Thanks very much. -Mike