docs-v2/content/influxdb/cloud/reference/flux/stdlib/strings/trimspace.md

1.1 KiB

title description aliases menu weight related
strings.trimSpace() function The strings.trimSpace() function removes leading and trailing spaces from a string.
/influxdb/cloud/reference/flux/functions/strings/trimspace/
influxdb_cloud_ref
name parent
strings.trimSpace Strings
301
/influxdb/cloud/reference/flux/stdlib/strings/trim
/influxdb/cloud/reference/flux/stdlib/strings/trimleft
/influxdb/cloud/reference/flux/stdlib/strings/trimright
/influxdb/cloud/reference/flux/stdlib/strings/trimprefix
/influxdb/cloud/reference/flux/stdlib/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) }))