On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote:
Hey,

I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind.

What I would like to do is filter out all spaces in a string and change the front letter to lower case:

    string m = "My Capital String";
    string lower = m
        .filter!(c => c != ' ')
.<executeAt>!(0, c => c.toLower) // executeAt does not exist
        .array.to!string;
    assert(lower == "myCapitalString");

or sth like

    m.filter!(...)
        .map!((element, int index) {
            if (index == 0)
                return element.toLower;
            else
break; // stop since we are done manipulating range
        });

Anyway to do this?

No need for regular expressions. D is powerful enough without them:

```
alias lowercased = (m, n) => m.take(n).asLowerCase.chain(m.drop(n));
```

https://run.dlang.io/is/cSL0si

Reply via email to