in reply to How to identify invalid reg. expr.?
Using the string form of eval() will do runtime compilation of the regex and therefore not break the program if it is invalid. Also note the abbreviation of 'regular expression' is commonly known as regex (and it's a lot easier to pronounce too ;-)my $format = "foo (bar] baz"; eval '$regex = qr/$format/;'; die "ack - $@" if $@; __output__ ack - Unmatched ( before HERE mark in regex m/foo ( << HERE bar] baz/ +at (eval 1) line 1.
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
• DANGER! Re: Re: How to identify invalid reg. expr.?
by merlyn (Sage) on Jun 05, 2002 at 15:45 UTC |