4

How to remove all occurrences of a string in another? I can do this using the following code:

std.array.replace: "the string".replace("the", "")

But I wonder if there is a dedicated function for this in phobos?

sigod
  • 3,514
  • 2
  • 21
  • 44
Denis Gladkiy
  • 2,084
  • 1
  • 26
  • 40

1 Answers1

7

Yes. It's correct function. But you might want to use it from std.string. Because if in future version something changes you'll still be using correct function.

From documentation of std.string:

The following functions are publicly imported:

std.array: replace replaceInPlace ...

sigod
  • 3,514
  • 2
  • 21
  • 44
  • 3
    remember too btw that replace does not work in place. So to replace the old one it is like `string changed = original.replace("thing", "else");` – Adam D. Ruppe Oct 02 '15 at 14:25