in reply to Regex Debugger?

Don't forget about such tools as YAPE::Regex::Explain, where the synopsis in the POD provides this simple example:

use YAPE::Regex::Explain; my $exp = YAPE::Regex::Explain->new($REx)->explain;

In the above example, let $REx be your regular expression as a single-quoted string or a qr// object.

If you print $exp, you'll get a nice table explaining each subexpression within the regular expression.

That's probably one of the more powerful tools for me.

Here is an example output from YAPE::Regex::Explain, when invoked as follows:

perl -MYAPE::Regexp::Explain -e "print YAPE::Regex::Explain->new('\bte +st(?: more)\b$')->explain();"

And the output...

The regular expression: (?-imsx:\btest(?: more)\b$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- test 'test' ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- more ' more' ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Perl also provides the use re qw/debug/; pragma, which can be used like this:

#!/usr/bin/perl use re 'debug'; m/ \b test regexp \b /x;

When you execute that you'll get a sort of compilation version of the regular expression, which is sometimes helpful in seeing what's going on (or wrong). This is discussed in perldebug and perldebuguts.


Dave