readln() returns new line charater

bearophile bearophileHUGS at lycos.com
Tue Dec 31 08:29:51 PST 2013


Stewart Gordon:

> I'd be inclined to define a function like
>
> string stripLineBreak(string s) {
>     while (s.length != 0 && s[$-1] != '\n' && s[$-1] != '\r') {
>         s = s[0..$-1];
>     }
>     return s;
> }

See the chop and chomp functions in std.string.

Bye,
bearophile


More information about the Digitalmars-d mailing list