digitalmars.D.learn - std.algorithm.splitter on string inserts \\ for every occurrence of \
- WhatMeWorry (14/14) Jun 19 2014 string path = environment["PATH"]; // get the value of the env
- Adam D. Ruppe (6/7) Jun 19 2014 The function isn't doing that conversion, that's just because
string path = environment["PATH"]; // get the value of the env variable PATH. writeln("Path is ", path); writeln(); auto paths = std.algorithm.splitter(path, ";"); writeln("Paths are ", paths); Path is E:\dmd2\windows\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32... Paths are ["E:\\dmd2\\windows\\bin", "C:\\Windows\\system32", "C:\\Windows", "C:\\Win... The function is perfect except it converts \ to \\. I presume this is because D uses the \ character as an escape character? Thanks in advance.
Jun 19 2014
On Friday, 20 June 2014 at 02:41:06 UTC, WhatMeWorry wrote:The function is perfect except it converts \ to \\.The function isn't doing that conversion, that's just because when you do writeln() on a range or array, it prints it out in a format that can be read back. That's also why it put the [] and quotes around the entries - they weren't literally in the result string, it was just a printing convention.
Jun 19 2014