lower case only first letter of word

Mengu mengukagan at gmail.com
Tue Dec 5 15:00:18 UTC 2017


On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote:
> On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote:
>> On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak 
>> wrote:
>>>>> [...]
>>
>> Yes, this is not what I want. I want to convert only the first 
>> letter of the word to lower case and left all the others 
>> immutable. similar to PHP's lcfirst():
>>
>> http://php.net/manual/en/function.lcfirst.php
>
> this is how i'd do it:
>
> string upcaseFirst(string wut) {
>   import std.ascii : toUpper;
>   import std.array : appender;
>
>   auto s = appender!string;
>   s ~= wut[0].toUpper;
>   s ~= wut[1..$];
>   return s.data;
> }

however a solution that does not allocate any memory would be a 
lot better.


More information about the Digitalmars-d-learn mailing list