2

文字列がサフィックスで終わっているかどうかをテストする関数が必要です。このタスクには「lastIndexOf」を使用できますが、標準の phobos 機能があるのだろうか?

4

1 に答える 1

7

はい、そうです。std.algorithm.endsWith文字列だけでなく、他の配列や範囲でも機能します。例:

void main()
{
    import std.algorithm.searching, std.stdio;
    auto s = "Sunday";
    auto b = s.endsWith("ay");
    writeln(b); // true
}
于 2014-09-11T12:43:21.080 に答える