Documentation

strings.trimPrefix() function

The strings.trimPrefix() function removes a prefix from a string. Strings that do not start with the prefix are returned unchanged.

Output data type: String

import "strings"

strings.trimPrefix(v: "123_abc", prefix: "123")

// returns "_abc"

Parameters

v

The string value to trim.

Data type: String

prefix

The prefix to remove.

Data type: String

Examples

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

data
  |> map(fn: (r) => ({
      r with
      sensorID: strings.trimPrefix(v: r.sensorId, prefix: "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: