in reply to zero-width assertions in perl regular expression
print:use strict; use warnings; use YAPE::Regex::Explain; for my $regexp ('\babc\z','\babc\Z') { print YAPE::Regex::Explain->new($regexp)->explain, "\n"x3; }
The regular expression: (?-imsx:\babc\z) 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): ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- abc 'abc' ---------------------------------------------------------------------- \z the end of the string ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- The regular expression: (?-imsx:\babc\Z) 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): ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- abc 'abc' ---------------------------------------------------------------------- \Z before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
|
---|