aplonis has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test RegEx Validity
by Your Mother (Archbishop) on Nov 28, 2004 at 01:41 UTC | |
by BUU (Prior) on Nov 28, 2004 at 02:32 UTC | |
by tphyahoo (Vicar) on Nov 29, 2004 at 14:31 UTC | |
by BUU (Prior) on Nov 30, 2004 at 04:52 UTC | |
|
Re: Test RegEx Validity
by Zaxo (Archbishop) on Nov 28, 2004 at 01:58 UTC | |
by bart (Canon) on Nov 28, 2004 at 03:02 UTC | |
by benizi (Hermit) on Dec 07, 2004 at 18:49 UTC | |
|
Re: Test RegEx Validity
by simonm (Vicar) on Nov 28, 2004 at 01:12 UTC | |
by Fletch (Bishop) on Nov 28, 2004 at 01:28 UTC | |
|
Re: Test RegEx Validity
by Prior Nacre V (Hermit) on Nov 29, 2004 at 04:42 UTC |