Removing whitespace duplicates

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 20 15:21:09 PDT 2014


Nordlöw:

> How can I extend
>
> string line = "car    wash";
>
> line.strip.splitter!isWhite.joiner("_").to!string
>
> so that
>
> car   wash
>
> becomes
>
> car_wash
>
> and not
>
> car___wash
>
> ?

Use std.string.tr.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list