d的split与joiner.
import std.stdio : writeln;
import std.algorithm : joiner;
import std.array : split;
bool isWhite(dchar c) @safe pure nothrow @nogc
{
return c == ' ' || c == ';' ||
(c >= 0x09&& c <= 0x0D);
}
void main()
{
string str = "a\nb c\t;d e f;a b ";
str.split!isWhite.joiner.writeln(); //abcdefab
}
浙公网安备 33010602011771号