docs-v2/content/flux/v0.x/stdlib/strings/trimsuffix.md

1.2 KiB

title description aliases menu weight related introduced
strings.trimSuffix() function The `strings.trimSuffix()` function removes a suffix from a string. Strings that do not end with the suffix are returned unchanged.
/influxdb/v2.0/reference/flux/functions/strings/trimsuffix/
/influxdb/v2.0/reference/flux/stdlib/strings/trimsuffix/
/influxdb/cloud/reference/flux/stdlib/strings/trimsuffix/
flux_0_x_ref
name parent
strings.trimSuffix strings
301
/flux/v0.x/stdlib/strings/trim
/flux/v0.x/stdlib/strings/trimleft
/flux/v0.x/stdlib/strings/trimright
/flux/v0.x/stdlib/strings/trimprefix
/flux/v0.x/stdlib/strings/trimspace
0.27.0

The strings.trimSuffix() function removes a suffix from a string. Strings that do not end with the suffix are returned unchanged.

Output data type: String

import "strings"

strings.trimSuffix(v: "123_abc", suffix: "abc")

// returns "123_"

Parameters

v

The string value to trim.

suffix

The suffix to remove.

Examples

Remove a suffix from all values in a column
import "strings"

data
    |> map(fn: (r) => ({r with sensorID: strings.trimSuffix(v: r.sensorId, suffix: "_s12")}))