in reply to Re: Understanding regex
in thread Understanding regex

You know, some times one just feels like an idiot :D. Thanks.

Replies are listed 'Best First'.
Re^3: Understanding regex
by Fletch (Bishop) on Apr 29, 2005 at 12:57 UTC

    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 ----------------------------------------------------------------------