in reply to Re: How to capture quantified repeats?
in thread How to capture quantified repeats?

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on Re^2: How to capture quantified repeats?

Replies are listed 'Best First'.
Re^3: How to capture quantified repeats?
by BrowserUk (Patriarch) on Sep 22, 2010 at 20:12 UTC
    was the other solution that is not satisfactory. Why not?

    Because, as you've found out, repeated captures don't work. (I've often wanted it myself.)

    splitting a thousand fields into an array takes about 300 times longer than selecting 3 fields out of the line

    Fair enough. One alternative is to repeat the capture manually. Something like:

    @jam = $ham =~ m/\t([^\t]+)\t+([^\t]+)\t+([^\t]+)/;; print @jam;; spam spam yam

    If the number required isn't known until runtime, you can generate the regex on the fly.

    Another possibility is to capture the whole lot in a single capture and then split it:

    ( $jam ) = $ham =~ m/^[^\t]*\t[^\t]*((?:\t[^\t]*){3})\t[^\t]*$/;; @jam = split /\t+/, $jam;; print @jam;; spam yam

    A real example would get answers that address the real problem.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks for your input.