in reply to Re: Re: Regex (lookahead) Confusion
in thread Regex (lookahead) Confusion
perl -MYAPE::Regex::Explain -e 'print YAPE::Regex::Explain->new(q/^(?: +([smtwhfa])(?!.*\1))*$/)->explain' The regular expression: (?-imsx:^(?:([smtwhfa])(?!.*\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): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- (?: group, but do not capture (0 or more times (matching the most amount possible)): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [smtwhfa] any character of: 's', 'm', 't', 'w', 'h', 'f', 'a' ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- (?! look ahead to see if there is not: ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \1 what was matched by capture \1 ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- )* end of grouping ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Regex (lookahead) Confusion
by ChrisR (Hermit) on Feb 06, 2004 at 13:40 UTC |