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?
Asked
Active
Viewed 70 times
2

Koz Ross
- 3,040
- 2
- 24
- 44
1 Answers
3
Yep, std.array.replace
import std.array, std.stdio;
void main()
{
replace("foo bar baz", " ", "\\ ").writeln();
}

Peter Alexander
- 53,344
- 14
- 119
- 168