Manipulate slice or specific element of range and return range

Timoses timosesu at gmail.com
Wed Mar 21 17:02:18 UTC 2018


On Wednesday, 21 March 2018 at 12:07:49 UTC, Simen Kjærås wrote:
> On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote:
> unittest {
>     assert("my capitalized string".capitalize == 
> "myCapitalizedString");
> }
>
> auto capitalize(string s) {
>     import std.regex, std.uni;
>
>     return s.replaceAll!(a => a[1].toUpper)(regex(" (.)"));
> }

Ty! This definitely put me on the right track regarding strings.


More information about the Digitalmars-d-learn mailing list