CamelCase in D

Example for versions D2

First line reads a line from standard input and converts it to lowercase. Second line replaces all non-letter characters with spaces (last parameter is attribute characters; g means that all matches of regular expression are replaced, not only the first one). Third line capitalizes words in string, removes leading and trailing spaces and replaces all sequences of spaces with a single space. Finally, the spaces are removed from the string, and the result is printed to standard output.

import std.stdio;
import std.string;
import std.regexp;
void main() {
    string text = tolower(readln());
    text = sub(text,"[^a-z]"," ","g");
    text = capwords(text);
    text = sub(text," ","","g");