in reply to Re^3: expanding the functionality of split
in thread expanding the functionality of split

I admit it, I can't see how this would work? Wouldn't you at least need /g to make this produce more than one capture?

(Said, with the distinct feeling that I'm missing something very obvious or very clever:)


Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

  • Comment on Re: Re^3: expanding the functionality of split

Replies are listed 'Best First'.
Re^5: expanding the functionality of split
by Aristotle (Chancellor) on Dec 11, 2002 at 15:06 UTC
    :) See perlre:
    (??{ code })

    WARNING: This extended regular expression feature is considered highly experimental, and may be changed or deleted without notice. A simplified version of the syntax may be introduced for commonly used idioms.

    This is a "postponed" regular subexpression. The code is evaluated at run time, at the moment this subexpression may match. The result of evaluation is considered as a regular expression and matched as if it were inserted instead of this construct.

    The code is not interpolated. As before, the rules to determine where the code ends are currently somewhat convoluted.

    The following pattern matches a parenthesized group:

    $re = qr{ \( (?: (?> [^()]+ ) # Non-parens without backtracking | (??{ $re }) # Group with matching parens )* \) }x;
    I just noticed I made an assumption too many myself - code is updated.

    Makeshifts last the longest.

      Okay. I get the idea. Recursive interpolation to build the regex.

      I'm aware of (??{}), i've even used it successfully a coupe of times, (thought I've failed many more:). I just hadn't recognised the recursive nature of the beast. I think it was the fact that you are using q// that threw me. Of course, now I see its necessary for what you are doing.


      Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
      Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
      Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
      Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.