in reply to Re: Re: Capturing brackets within a repeat group
in thread Capturing brackets within a repeat group

That's how I read that passage, too.

But I have no problem with the way repeating a capture works. The ()'s generate code to refer to a particular slot, since the numbering is static from left-to-right. The repeat redoes the same parens. It's no different from backtracking in that respect.

I'm sure you've figured this out:

/( (?: blah blah) {5} ) /x
Put the repeat inside the parens.

—John

Replies are listed 'Best First'.
Re: Re: Re: Re: Capturing brackets within a repeat group
by BrowserUk (Patriarch) on Jan 11, 2003 at 10:19 UTC

    The thing with doing that is that it captures the whole of the repeat group as a single entity, whereas I was hoping to capture each of the individual parts seperately.


    Examine what is said, not who speaks.

    The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

      I beleive in Perl 6 the repeat applied to a capture group will cause that number to be an array. Or you can explicitly name it with an array name. Something like that.

      I don't see why you shouldn't be able to capture separatly in principle, if there is a fixed upper number. But Perl 5 regex syntax doesn't support that. You could squish the redundancy by making the repeat stuff in a variable and interpolating it n times or with a x operator. That would give you the "in one place" nice thing for maintainability.