On Wed, 11 Mar 2015 00:00:38 +0000, dnoob wrote:
> Hello,
>
> I am parsing some text and I have the following;
>
> string text = "some very long text";
>
> foreach(line; splitter(text, [13, 10]))
> {
> foreach(record; splitter(line, '*'))
> {
> foreach(field; splitter(record, '='))
> {
> foreach(value; splitter(field, ','))
> {
> // do something...
> }
> }
> }
> }
>
> I know there is a better way to do that but I'm a total D noob.
>
> Thanks!
it depends of the thing you want to do. please, describe your task, as
the solutions can differ depending of your needs. if you needs only
values and don't care about everything other, this can help:
import std.regex;
import std.stdio;
void main () {
string text = "some,very=long,text*another=shit";
foreach (immutable v; text.splitter(regex("[,=*\n\r]"))) {
writeln(v);
}
}
signature.asc
Description: PGP signature
