Breaking a string down into words using D language


Keywords:string 


Question: 

I am new to using D, and I wanted to ask for help on a simple method of breaking down a string into words. My program takes text from a file and is supposed to count the number of words in that text.


1 Answer: 

splitter and walkLength can do this trivially.

void main()
{
    import std.stdio, std.algorithm, std.range, std.file;
    writeln(readText("file.txt").splitter.walkLength());
}