On Tuesday, 5 December 2017 at 13:31:17 UTC, Marc wrote:
Does D have a native function to capitalize only the first letter of the word? (I'm asking that so I might avoid reinvent the wheel, which I did sometimes in D)

// ----------------
module test;

import std.stdio;

void main()
{
    string myString = "heLlo WoRlD!";
    writeln( HereItIs(myString) );
}


string HereItIs(string someString)
{
    import std.uni : toLower;
    import std.ascii : toUpper;

return (someString.ptr[0].toUpper ~ someString[1..$].toLower);
}
// ------------------

Reply via email to