Outputs:use strict; use warnings; use YAPE::Regex::Explain; my $regex = qr/foo # Match starting at foo (?: # Complex expression: (?!baz) # make sure we're not at the beginning of baz . # accept any character )* # any number of times bar # and ending at bar /x; my $explanation = YAPE::Regex::Explain->new($regex)->explain; print $explanation;
The regular expression: (?x-ims:foo # Match starting at foo (?: # Complex expression: (?!baz) # make sure we're not at the beginning of baz . # accept any character )* # any number of times bar # and ending at bar ) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?x-ims: group, but do not capture (disregarding whitespace and comments) (case-sensitive) (with ^ and $ matching normally) (with . not matching \n): ---------------------------------------------------------------------- foo 'foo' ---------------------------------------------------------------------- (?: group, but do not capture (0 or more times (matching the most amount possible)): ---------------------------------------------------------------------- (?! look ahead to see if there is not: ---------------------------------------------------------------------- baz 'baz' ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- )* end of grouping ---------------------------------------------------------------------- bar 'bar' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
In reply to Re: Regex look ahead
by imp
in thread Regex look ahead
by pglenski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |