in reply to Re: Dynamic regexp from array values
in thread Dynamic regexp from array values
You could either build a regexmy $regex = join '|', map "\Q$_\E", @vals; doSomething() if $data =~ $regex;
Actually my $regex = qr(join '|', map "\Q$_\E", @vals) will optimize the pattern matching. See perldoc -f qr
Ciao!
--bronto
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Dynamic regexp from array values
by broquaint (Abbot) on Feb 12, 2003 at 12:16 UTC | |
|
Re: Re: Re: Dynamic regexp from array values
by ihb (Deacon) on Feb 12, 2003 at 20:08 UTC |