in reply to Reading Reg Exp
You could also try YAPE::Regex::Explain. Thanks to Toolic for suggesting this module in a previous post. Here is an example using one of your regexes:
#!perl use strict; use warnings; use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/(?:\w+\s+fish\s+){2}(\w+)\s+fish/i) +->explain(); __END__ The regular expression: (?i-msx:(?:\w+\s+fish\s+){2}(\w+)\s+fish) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?i-msx: group, but do not capture (case-insensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?: group, but do not capture (2 times): ---------------------------------------------------------------------- \w+ word characters (a-z, A-Z, 0-9, _) (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)) ---------------------------------------------------------------------- fish 'fish' ---------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ){2} end of grouping ---------------------------------------------------------------------- ( 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 ---------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- fish 'fish' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
Update: Link fixed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading Reg Exp
by JavaFan (Canon) on Aug 11, 2010 at 09:11 UTC | |
by kejohm (Hermit) on Aug 11, 2010 at 10:33 UTC | |
by JavaFan (Canon) on Aug 11, 2010 at 10:45 UTC | |
by kejohm (Hermit) on Aug 12, 2010 at 07:34 UTC | |
by JavaFan (Canon) on Aug 12, 2010 at 08:42 UTC | |
| |
by choroba (Cardinal) on Aug 11, 2010 at 10:49 UTC | |
by JavaFan (Canon) on Aug 11, 2010 at 10:54 UTC | |
|