chaining splitters
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 10 23:29:57 PDT 2015
On Wednesday, 11 March 2015 at 00:00:39 UTC, 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!
I don't understand what you want to do. Maybe you want to do this:
import std.stdio;
import std.string;
void main() {
string text = "some very long text";
foreach(line; text.split) {
writeln(line);
}
}
More information about the Digitalmars-d-learn
mailing list