Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-19 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found