Splitting a string on multiple tokens
jerro
a at a.com
Tue Oct 9 18:57:02 PDT 2012
On Wednesday, 10 October 2012 at 00:18:17 UTC, ixid wrote:
> Is there an effective way of splitting a string with a set of
> tokens? Splitter feels rather limited and multiple passes gives
> you an array of arrays of strings rather than an array of
> strings. I'm not sure if I'm missing an obvious application of
> library methods or if this is absent.
You can use std.regex.splitter like this:
auto r = regex(`,| |(--)`);
auto str = "string we,want--to,split";
writeln(splitter(str, r)); //will pring ["string", "we", "want",
"to", "split"]
More information about the Digitalmars-d-learn
mailing list