Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

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

I'm sure we discussed this technique before, but I can't find it in the archives.

Do you remember a thread? :)

update

well I deciphered it in the meantime, it's not operating on match-groups but the /x /g ° modifier.

That'll repeat a search where the last match ended, and return all results in list context till it fails

DB<139> p 0123456789abcdefghijklmnopqrstuvwxyz DB<139> x m{ .... }xg 0 0123 1 4567 2 '89ab' 3 'cdef' 4 'ghij' 5 'klmn' 6 'opqr' 7 'stuv' 8 'wxyz' DB<140>

with a negative look-behind (?<! ) we can filter out all matches after the initial 4

DB<140> x m{ (?<! (?: .... ){4} ) .... }xg 0 0123 1 4567 2 '89ab' 3 'cdef' DB<141>

an or condition | helps matching after the fail.

DB<142> x m{ (?<! (?: .... ){4} ) .... | .+ }xg 0 0123 1 4567 2 '89ab' 3 'cdef' 4 'ghijklmnopqrstuvwxyz' DB<143>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) thanks AnomalousMonk++ for spotting :)


In reply to Re^2: mysteries of regex substring matching (explanation) by LanX
in thread mysteries of regex substring matching by smile4me

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 studying the Monastery: (5)
As of 2024-04-25 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found