I like simonm's and especially Fletch's tricks. I'll also offer that it's possible to write a colossally bad regular expression that might take hours or decades to match; intentionally or accidentally. So if this isn't a personal box project, you should probably wrap the actual execution of the expression in a time out alarm; something like so (mostly from the Cookbook):
eval { local $SIG{ALRM} = sub { die "Bad rx timed out" }; alarm 5; # start the timer eval { # the user's rx is run here... }; alarm 0; # clear the timer }; alarm 0; # in case something else went wrong die $@ if $@ and $@ !~ /rx timed out/;
In reply to Re: Test RegEx Validity
by Your Mother
in thread Test RegEx Validity
by aplonis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |