Test for (in)valid regex


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # Test for (in)valid regex
  2. # perl regex
  3. #
  4. # (you may need to disable warnings)
  5.  
  6. my $pattern = shift;
  7. my $regex = eval { qr/$pattern/ };
  8. die "Your regex doesn't seem valid : $@" if $@;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.