You could always use the qr// operator to compile the regex and check the success of the compilation using eval.
--my $pat = <STDIN>; # random nonsense from a user my $re = eval { qr/$pat/ }; die "Nasty regex!: $@\n" if $@;
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
In reply to Re: Checking user input on dynamic regular expressions
by davorg
in thread Checking user input on dynamic regular expressions
by cLive ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |