in reply to Re^2: Understanding regex
in thread Understanding regex
Install YAPE::Regex::Explain if you don't already have it, as it can break out a regex into a more verbose format that can help you spot things like that.
$ perl -MYAPE::Regex::Explain -le 'print YAPE::Regex::Explain->new(qr/ +([()\w\s-]+): \1/ )->explain' The regular expression: (?-imsx:([()\w\s-]+): \1) 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): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [()\w\s-]+ any character of: '(', ')', word characters (a-z, A-Z, 0-9, _), whitespace (\n, \r, \t, \f, and " "), '- ' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- : ': ' ---------------------------------------------------------------------- \1 what was matched by capture \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Understanding regex
by eXile (Priest) on Apr 29, 2005 at 13:12 UTC |