in reply to Validating a Regexp
That seems to do the job.sub is_valid_re { eval { qr/$_[0]/ }; return $@ ? 'NO' : 'YES'; } my @regexes = qw(a[hjg].* *a[hj); print is_valid_re($_), $/ for @regexes; __output__ YES NO
_________
broquaint
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Validating a Regexp
by Juerd (Abbot) on Jul 29, 2002 at 17:46 UTC |