http://qs321.pair.com?node_id=373416


in reply to How will my regular expression match?

Allthough, this is repetitive, using one-liners like:
perl -e "use re 'debug'; print 'this is a demo' =~ /\w+/;"
helped me more than once (it's even more useful with complex regexes :-). It'a a shame that you have to dig into perldebug to find it. I think it should be mentioned in perlre also.

2share!2flame...

Replies are listed 'Best First'.
Re^2: How will my regular expression match?
by hv (Prior) on Jul 11, 2004 at 03:13 UTC

    I use this a lot, usually with the shorter command-line invocation ('-Dr', available if perl was built with debugging enabled). However the output was designed primarily for internals debugging, and is likely to be more scary than helpful to the casual user.

    Various people have taken advantage of the information it provides to offer a friendlier interface to regexp debugging. Though I haven't tried any of them, I'm aware of ReBug (I believe this is open source, but I can't get to the website: the author gave a talk on it at the 2001 OSCON), Komodo (commercial, with "try before you buy"), and The Regex Coach ("donationware", donate if you like it) which was recently mentioned on PM.

    Hugo

Re^2: How will my regular expression match?
by diotalevi (Canon) on Jul 11, 2004 at 04:00 UTC
    There's also the shorter, perl -Mre=debug -e ' ... ' for those people without a debugging perl.