in reply to Input Validation - verifying a string is a properly formatted regular expression
The problem here is that if $Anytext doesn't match the RE, it'll tell me the RE is invalid
If $RE is not a valid regex, then it will throw an error, which you can catch with a BLOCK eval
.my $is_valid = eval { qr{$RE}; 1 }
should work (not tested).
You could also use some modules like Regexp::Parser or YAPE::Regex if you don't want to interpolate the regex without knowing first if it's valid.
|
|---|