Get "discarded" data from std.regex.splitter (or something else?)

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Jan 16 14:33:29 PST 2014


17-Jan-2014 00:52, Steven Schveighoffer пишет:
>
> writeln(splitter("abc123def456", regex("[0-9]+", "g")));
>
> outputs:
>
> ["abc", "def", ""]
>
> But what if I want the "123" and "456" tokens too? Is there a way to do
> that?

Well these 3 pieces are _slices_ of the original input, and with a bit 
of calculations on .ptr and .length you can figure out what's in between.

Also you can just use matchAll which too, does return slices. It could 
be seen as dropping all in between matches ;)

>
> -Steve


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list