docs-v2/content/flux/v0.x/stdlib/regexp/replaceallstring.md

1.3 KiB

title description aliases menu weight introduced
regexp.replaceAllString() function The `regexp.replaceAllString()` function replaces all regular expression matches in a string with a specified replacement.
/influxdb/v2.0/reference/flux/functions/regexp/replaceallstring/
/influxdb/v2.0/reference/flux/stdlib/regexp/replaceallstring/
/influxdb/cloud/reference/flux/stdlib/regexp/replaceallstring/
flux_0_x_ref
name parent
regexp.replaceAllString regexp
301 0.33.6

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.

v

The string value to search.

t

The replacement for matches to r.

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