Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串"foo bar baz",想把它变成"foo\ bar\ baz". 缺少手动黑客方法(调用split,然后使用适当的分隔符重新加入),还有其他方法可以做到这一点吗?replacePhobos 中是否存在类似函数的功能?
"foo bar baz"
"foo\ bar\ baz"
split
replace
是的,std.array.replace
std.array.replace
import std.array, std.stdio; void main() { replace("foo bar baz", " ", "\\ ").writeln(); }