std.algorithm.splitter on string inserts \\ for every occurrence of \
WhatMeWorry via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 19 19:41:04 PDT 2014
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.
More information about the Digitalmars-d-learn
mailing list