January 16, 2014
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?

-Steve
January 16, 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