I've got a Perl/Tk script that let's users type in any old RegEx into a text widget. That RegEx is then used as a file filter. I can't control what they type in. So I need to test their RegEx for validity before it's employed.
That is, I want a sub that returns a 1 when the user's RegEx is valid, 0 otherwise. Like so:
sub re_valid_test {
my ($re) = @_;
my %bool = 0;
...some way of setting $bool to 1 if $re is valid...
return $bool;
}
Perl already knows how to fault an invalid RegEx. How do I tap into that?
In reply to Test RegEx Validity by aplonis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |