Comment detail

LL Golf Hole 2 - 文字列に含まれる単語の最初の文字を大文字にする (Nested Flatten)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
private import std.string, std.regexp;

string totitle(in string str) {
    return str.sub(r"\b[a-z]", (RegExp m){return m[0].toupper();}, "g");
}

unittest {
    assert("LL future".totitle() == "LL Future");
    assert("LL day and night".totitle() == "LL Day And Night");
}

Index

Feed

Other

Link

Pathtraq

loading...