The regex has no syntax that was added after Perl version 5.6, so YAPE::Regex::Explain may be helpful.
c:\@Work\Perl\monks>perl -wMstrict -le
"use YAPE::Regex::Explain;
;;
my $rx = qr/[(](\w+)[^(]+[(](\w+)[^:]+:\s+(\w+).*?slack[^-]+(-\d+)/s;
;;
print YAPE::Regex::Explain->new($rx)->explain;
"
The regular expression:
(?s-imx:[(](\w+)[^(]+[(](\w+)[^:]+:\s+(\w+).*?slack[^-]+(-\d+))
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?s-imx: group, but do not capture (with . matching
\n) (case-sensitive) (with ^ and $ matching
normally) (matching whitespace and #
normally):
----------------------------------------------------------------------
[(] any character of: '('
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
[^(]+ any character except: '(' (1 or more times
(matching the most amount possible))
----------------------------------------------------------------------
[(] any character of: '('
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
[^:]+ any character except: ':' (1 or more times
(matching the most amount possible))
----------------------------------------------------------------------
: ':'
----------------------------------------------------------------------
\s+ whitespace (\n, \r, \t, \f, and " ") (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
( group and capture to \3:
----------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \3
----------------------------------------------------------------------
.*? any character (0 or more times (matching
the least amount possible))
----------------------------------------------------------------------
slack 'slack'
----------------------------------------------------------------------
[^-]+ any character except: '-' (1 or more times
(matching the most amount possible))
----------------------------------------------------------------------
( group and capture to \4:
----------------------------------------------------------------------
- '-'
----------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
----------------------------------------------------------------------
) end of \4
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
Update: Also see davido's on-line Perl Regular Expression Tester for post-5.6 syntax.
|