Iterating chars by Word
Ali Çehreli
acehreli at yahoo.com
Fri Nov 13 06:40:28 UTC 2020
On 11/12/20 9:14 PM, Виталий Фадеев wrote:
> Is:
> wchar[] chars; // like a: "import core.sys.windows.windows;\nimport
> std.conv : to;\n"
>
> Goal:
> foreach ( word; chars.byWord )
> {
> // ...
> }
>
> Iterating chars by Word...
> How to ? ( simple, fast, low memory, beauty, perfect )
import std.stdio;
import std.algorithm;
import std.uni;
void main() {
auto s = "Виталий abcçdefgğhı Фадеев"w;
auto words = s.splitter;
words.writefln!"%-(%s\n%)";
}
Note that splitter() is different from splitter!isWhite. The version I
used above removes empty parts. (I used multiple spaces in one place but
the output contains only three parts.)
Виталий
abcçdefgğhı
Фадеев
Ali
More information about the Digitalmars-d-learn
mailing list