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
}
posted @ 2021-12-09 09:10  zjh6  阅读(10)  评论(0)    收藏  举报  来源