Documentation

strings.trimSuffix() function

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.

Data type: String

suffix

The suffix to remove.

Data type: String

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")
    })
  )

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: