Neigher \K nor /r existed in Perl 5.6.x, which is the latest version of the regexp syntax that YAPE::Regex::Explain supports. (This is documented, and would have been pretty easy to test.)
perl -MYAPE::Regex::Explain -E 'say YAPE::Regex::Explain->new(q/@{[s". +."."gr]}\K$"/)->explain'
...produces the following output (assuming a Perl that is recent enough to understand \K and /r):
The regular expression: (?-imsx:@{[s".."."gr]}\K$") 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): ---------------------------------------------------------------------- @{ '@{' ---------------------------------------------------------------------- [s".."."gr] any character of: 's', '"', '.', '.', '"', '.', '"', 'g', 'r' ---------------------------------------------------------------------- } '}' ---------------------------------------------------------------------- \K 'K' ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- " '"' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
...which obviously is totally wrong. It completely misses that @{[.....]} interpolates code into a string (it instead thinks it's looking at a character class), it mistakes \K for literal "K", and mistakes $" for an end of line/string metacharacter, followed by a literal ", when it really should see the Perl special variable. Add to that the fact that it couldn't possibly understand the /r semantics, and the fact that we're using the regexp engine re-entrantly (which I don't think used to be possible), and it's a hopeless case for poor old YAPE::Regex::Explain.
I too am confused by why he demonstrated /@{[s".."."gr]}\K$"//; I don't see it mentioned among the submissions I viewed, and I don't see any mechanism for it actually doing what it's supposed to. It certainly doesn't match the code in the link provided.
Dave
In reply to Re^2: strange usage of s///
by davido
in thread strange usage of s/// [solved: Perl 5.14 and 5.16 bug]
by brx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |