docs-v2/content/v2.0/reference/flux/functions/strings/trim.md

1.2 KiB

title description menu weight related
strings.trim() function The strings.trim() function removes leading and trailing characters specified in the cutset from a string.
v2_0_ref
name parent
strings.trim Strings
301
/v2.0/reference/flux/functions/strings/trimleft
/v2.0/reference/flux/functions/strings/trimright
/v2.0/reference/flux/functions/strings/trimprefix
/v2.0/reference/flux/functions/strings/trimsuffix
/v2.0/reference/flux/functions/strings/trimspace

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

Output data type: String

import "strings"

strings.trim(v: ".abc.", cutset: ".")

// 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
import "strings"

data
  |> map(fn: (r) => ({
      r with
      variables: strings.trim(v: r.variables, cutset: ".")
    })
  )