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>
°) thanks AnomalousMonk++ for spotting :)
-
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.
|