in reply to Question on evaulating a user built regex

What you need to do is place the regex inside the m// operator, then print the match. If you are trying a substitution, then use the s// operator. Eval is unnecesarry.

$user_text =~ m/$user_regex/; print $&;
Cheers,
Erik

Replies are listed 'Best First'.
Re: Re: Question on evaulating a user built regex
by Popcorn Dave (Abbot) on Apr 22, 2002 at 16:05 UTC
    I'm letting the user build the expression, including the regex operator so I need a way for the string to be evaluated at runtime as a regex.
      Then you'll want eval "\$user_text =~ $regex".

      =cut
      --Brent Dax
      There is no sig.