Compress spaces to one space

bearophile bearophileHUGS at lycos.com
Tue Feb 21 04:32:32 PST 2012


Andrej Mitrovic:

> Is there a Phobos function to compress all spaces to just one space in a string?
> 
> E.g. " foo   bar             "
> becomes: " foo bar "

import std.string;
void main() {
    assert(" foo   bar             ".squeeze() == " fo bar ");
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list