in reply to Re: Test RegEx Validity
in thread Test RegEx Validity
There's no need to actually use it in the eval, and you can save off the result and use it after the check.
sub validate_re { my $re = shift; eval { $re = qr/$re/ }; return $@ ? undef : $re }
That will return either an already compiled regexp or undef (and $@ will indicate what was wrong in that case).
|
|---|