Re: RFC 110 (v3) counting matches
[email protected] (Jonathan Scott Duff) Tue, 5 Sep 2000 11:01:06 -0500
| Newsgroups | perl.perl6.language.regex |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Aug 31, 2000 at 12:52:23PM -0400, Joe McMahon wrote:
>
> /($pat1)($pat2)($pat3)(?{sub1(@\)$pat4|?{sub2(@\)}$pat5|?{sub3(@\)})/
>
> This would translate to "if pat1pat2pat3 matches, call sub1 with all the
> matches to that point if pat4 matches afterward, otherwise call sub2
> with all the matches if pat5 matches, else just call sub3." The key bit
> here is that you pass over the sub call, deferring it until you've
> decided if the whole match worked, then picking the one that succeeded
> and calling it. If you don't like the syntax, please feel free to
> propose another.
Hmm... Isn't that just equivalent to this (expanded for readability):
/
($pat1)($pat2)($pat3)
(?:
$pat4(?{sub1($1,$2,$3)}) |
$pat5(?{sub2($1,$2,$3)}) |
(?{sub3($1,$2,$3)})
)
/x;
?
If so, all we're missing is @\
> @\ seemed a good mnemonic for "the array of backreferences I already
> matched".
Yes, it does.
-Scott
--
Jonathan Scott Duff
[email protected]