Documentation

regexp.replaceAllString() function

The regexp.replaceAllString() function replaces all regular expression matches in a string with a specified replacement.

Output data type: String

import "regexp"

regexp.replaceAllString(r: /a(x*)b/, v: "-ab-axxb-", t: "T")

// Returns "-T-T-"

Parameters

r

The regular expression used to search v.

Data type: Regexp

v

The string value to search.

Data type: String

t

The replacement for matches to r.

Data type: String

Examples

Replace regular expression matches in string column values
import "regexp"

data
  |> map(fn: (r) => ({
      r with
      message: r.message,
      updated_message: regexp.replaceAllString(
        r: /cat|bird|ferret/,
        v: r.message,
        t: "dog"
      )
  }))

New! Cloud or OSS?

InfluxDB OSS 2.0 release candidate 0

InfluxDB OSS v2.0.rc0 includes breaking changes that require a manual upgrade from all alpha and beta versions. For information, see:

Upgrade to InfluxDB OSS v2.0.rc0