문제

I have a string "foo bar baz", and would like to turn it into "foo\ bar\ baz". Short of the hand-hacking method (call split, then re-join with the appropriate separator), is there another way I can do this? Does something like a replace function exist in Phobos?

도움이 되었습니까?

해결책

Yep, std.array.replace

import std.array, std.stdio;
void main()
{
    replace("foo bar baz", " ", "\\ ").writeln();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top