in reply to Regex tutor in Perl/Tk

The idea is definitely cool, but there are a couple bugs in the execution: Also, it would be much cooler if you could show what the regex did element by element. For example, you could turn on /x by default, split the RE on whitespace, and show both what each prefix matches, and what each matches with the rest of the RE as a lookahead assertion (untested):
local $_ = $string_to_match; my @reparts = split ' ', $re; my $pre = ''; while (@reparts) { $pre .= shift @reparts; print "$pre w/ lookahead: ", /$pre (?=@reparts)/x, "\n"; print "Prefix $pre: ", /$pre/x, "\n"; } print "Shebang entier: ", /$pre/x, "\n";
/s

Replies are listed 'Best First'.
Re: Re: Regex tutor in Perl/Tk
by Popcorn Dave (Abbot) on Jul 01, 2002 at 04:27 UTC
    Thanks for the feedback!

    I thought that it was at least stable. I'll have to go back and have a look as soon as I finish my current project.

    As far as showing the execution, I believe that BooRadley(?) is either in process or has done something like that. Mine is just a simple tool to check a regex for beginners to test their regexes to see if they're doing what they expect them to do so as to help speed up their regex debugging.

    Actually it's helped me out a few times when I was trying to construct a regex that I wasn't sure of, so hopefully someone else can make use of it too. : )

    Some people fall from grace. I prefer a running start...