strings.replaceAll() function

The strings.replaceAll() function replaces all non-overlapping instances of a substring with a specified replacement.

*Output data type: String*

  1. import "strings"
  2. strings.replaceAll(v: "oink oink oink", t: "oink", u: "moo")
  3. // returns "moo moo moo"

Parameters

v

The string value to search.

*Data type: String*

t

The substring to replace.

*Data type: String*

u

The replacement for all instances of t.

*Data type: String*

Examples

Replace string matches
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. content: strings.replaceAll(v: r.content, t: "he", u: "her")
  6. })
  7. )

Related articles