use YAPE::Regex::Explain;
my $exp = YAPE::Regex::Explain->new($REx)->explain;
####
perl -MYAPE::Regexp::Explain -e "print YAPE::Regex::Explain->new('\btest(?: more)\b$')->explain();"
####
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
----------------------------------------------------------------------
####
#!/usr/bin/perl
use re 'debug';
m/
\b
test regexp
\b
/x;