in reply to Applying a RegEx in a variable
Hello
Try reading in perlop about the qr operator. Here is an example about how it can be used:
Hope this helps,,,my $String="1234A4321"; my $RegEx=qr/a/i; $String =~ $RegEx; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none","\ +n"; # Match: A Pre: 1234 Post: 4321
Aziz,,,
Update: Yes, you got the right idea there using
$re = eval "qr$regexp_val";Make sure you trust the source of your regexp before feeding it to eval.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Applying a RegEx in a variable
by ChOas (Curate) on Aug 10, 2001 at 13:59 UTC |
In Section
Seekers of Perl Wisdom