strings.trim() function

The strings.trim() function removes leading and trailing characters specified in the cutset from a string.

*Output data type: String*

  1. import "strings"
  2. strings.trim(v: ".abc.", cutset: ".")
  3. // returns "abc"

Parameters

v

String to remove characters from.

*Data type: String*

cutset

The leading and trailing characters to remove from the string. Only characters that match the cutset string exactly are trimmed.

*Data type: String*

Examples

Trim leading and trailing periods from all values in a column
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. variables: strings.trim(v: r.variables, cutset: ".")
  6. })
  7. )

Related articles