从D中的字符串中删除子字符串

Den*_*kiy 3 d phobos

如何删除另一个字符串中出现的所有字符串?我可以使用以下代码执行此操作:

std.array.replace: "the string".replace("the", "")
Run Code Online (Sandbox Code Playgroud)

但我想知道在phobos中是否有专门的功能?

sig*_*god 6

是.这是正确的功能.但是你可能想要使用它std.string.因为如果将来某些版本发生变化,您仍将使用正确的功能.

来自以下文件std.string:

以下功能是公开导入的:

std.array:...replace replaceInPlace

  • 记得太btw,替换不起作用.所以要替换旧的,就像`string changed = original.replace("thing","else");` (3认同)