jovo wrote:
"Andrei Alexandrescu" <[email protected]> wrote in message
news:[email protected]...
Looks simple but it isn't. How do you advance to the next match?
foreach (m; "abracadabra".match("(.)a", "g")) writeln(m.capture[0]);
This should print:
r
c
d
r
There's need to make progress in the matching, not in the capture. How do
you distinguish among them?
Andrei
foreach(capture; match(s, r))
foreach(group; capture)
writeln(group);
The consecrated terminology is:
foreach(match; match(s, r))
foreach(capture; match)
writeln(capture);
"Group" is a group defined without an intent to capture. A "capture" is
a group that also binds to the state of the match.
Anyhow... this can be done but things get a tad more confusing for other
uses. How about this:
foreach(match; match(s, r))
foreach(capture; match.captures)
writeln(capture);
?
Andrei