While we're at it: what's the best way to parse in a formatted manner? For example, if I want to get 5 hexadecimal digits converted into an uint? And I want to simultaneously advance the string?
"sscanf" seems fiddly and unsafe. On 13 January 2012 22:56, bearophile <bearophileh...@lycos.com> wrote: > Timon Gehr: > >> readln() includes the trailing newline character in the resulting >> string. You can use std.string.strip to remove leading and trailing >> whitespace: > > Time ago I have asked Andrei to modify the to!int conversion to work as > Python, ignoring leading and trailing whitespace: > >>>> s = "123\n" >>>> int(s) > 123 > > But he didn't change it. I don't think people use parse at their first try. > > Bye, > bearophile