in reply to Regex tester

Wow, very nice. I'm going to play around with that one for a bit. I just started learning regex's in depth, so this is a great tool. I have one I constructed as well, which might be useful, if just a simple match test is your aim:
#!usr/bin/perl $my_string = ""; $my_regx = ""; # This program tests regular expressions against a match. if ($my_string =~ /$my_regx/x) print "Matched: " . "\"" . $& . "\"" . "\n"; # print matc +h print "Before match: " . "\"" . $` . "\"" . "\n"; # print data + before match print "After match: " . "\"" . $' . "\"" . "\n"; # print data + after match }else { # do nothing } # end if print "Rockstar Programming Inc. All Rights Reserved\n";
So, now I have yours to explore with and maybe my much simpler "matcher" could possibly be of use to you :)

Replies are listed 'Best First'.
Re^2: Regex tester
by GrandFather (Saint) on Aug 24, 2008 at 21:43 UTC

    There are a few things here that could use a little tidying. First off, the mandatory mantra: Always use strictures (use strict; use warnings; - see The strictures, according to Seuss).

    Of more immediate benefit: if you find you need to include double quote character in a string use qq for quoting instead of " (see perlop's Quote and Quote-like Operators). For example your print statements become:

    print qq{Matched: "$&"\n}; # print match print qq~Before match: "$`"\n~; # print data before match print qq|After match: "$'"\n|; # print data after match

    although you may wish to use a here-doc instead (look for here-doc in the same docs mentioned above):

    print <<STUFF; Matched: "$&" Before match: "$`" After match: "$'" STUFF

    Perl reduces RSI - it saves typing