docs-v2/content/influxdb/cloud/reference/flux/stdlib/regexp/compile.md

1.0 KiB

title description aliases menu weight
regexp.compile() function The `regexp.compile()` function parses a regular expression and, if successful, returns a Regexp object that can be used to match against text.
/influxdb/cloud/reference/flux/functions/regexp/compile/
influxdb_cloud_ref
name parent
regexp.compile Regular expressions
301

The regexp.compile() function parses a regular expression and, if successful, returns a Regexp object that can be used to match against text.

Output data type: Regexp

import "regexp"

regexp.compile(v: "abcd")

// Returns the regexp object `abcd`

Parameters

v

The string value to parse into a regular expression.

Data type: String

Examples

Use a string value as a regular expression
import "regexp"

data
  |> map(fn: (r) => ({
      r with
      regexStr: r.regexStr,
      _value: r._value,
      firstRegexMatch: findString(
        r: regexp.compile(v: regexStr),
        v: r._value
      )
    })
  )