Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Perl allows a regular expression to match multiple times with the "g" switch past the end. Each individual match can then be looped over, as described in the Global Matching subsection of the <a href="http://perldoc.perl.org/perlretut.html#Using-regular-expressions-in-Perl" rel="nofollow noreferrer">Using Regular Expressions in Perl section of the Perl Regex Tutorial</a>:</p> <pre><code>while(/(x(?&lt;foo&gt;.))+/g){ say "&amp;: ", $&amp;; say "foo: ", $+{foo}; } </code></pre> <p>This will produce an iterated list:</p> <pre><code>&amp;: xa foo: a &amp;: xb foo: b &amp;: xc foo: c </code></pre> <p>Which still isn't what you want, but it's really close. Combining a global regex (/g) with you previous local regex probably will do it. Generally, make a capturing group around your repeated group, then re-parse just that group with a global regex that represents just a single iteration of that group, and iterate over it or use it as a list.</p> <p>It looks like a question fairly similar to this one- at least in answer, if not forumlation- has been answered by someone much more competent at Perl than I: <a href="https://stackoverflow.com/questions/467800/is-there-a-perl-equivalent-of-pythons-re-findall-re-finditer-iterative-regex-re">"Is there a Perl equivalent of Python's re.findall/re.finditer (iterative regex results)?"</a> You might want to check the answers for that as well, with more details about the proper use of global regexes. (Perl isn't my language, I just have an unhealthy appreciation for regular expressions.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload