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

958 B

title description menu weight related
strings.trimSpace() function The strings.trimSpace() function removes leading and trailing spaces from a string.
v2_0_ref
name parent
strings.trimSpace Strings
301
/v2.0/reference/flux/functions/strings/trim
/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

The strings.trimSpace() function removes leading and trailing spaces from a string.

Output data type: String

import "strings"

strings.trimSpace(v: "  abc  ")

// returns "abc"

Parameters

v

String to remove spaces from.

Data type: String

Examples

Trim leading and trailing spaces from all values in a column
import "strings"

data
  |> map(fn: (r) => ({ r with userInput: strings.trimSpace(v: r.userInput) }))