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

980 B

title description aliases menu weight
regexp.matchRegexpString() function The `regexp.matchRegexpString()` function tests if a string contains any match to a regular expression.
/influxdb/cloud/reference/flux/functions/regexp/matchregexpstring/
influxdb_cloud_ref
name parent
regexp.matchRegexpString Regular expressions
301

The regexp.matchRegexpString() function tests if a string contains any match to a regular expression.

Output data type: Boolean

import "regexp"

regexp.matchRegexpString(r: /(gopher){2}/, v: "gophergophergopher")

// Returns true

Parameters

r

The regular expression used to search v.

Data type: Regexp

v

The string value to search.

Data type: String

Examples

Filter by columns that contain matches to a regular expression
import "regexp"

data
  |> filter(fn: (r) =>
    regexp.matchRegexpString(
      r: /Alert\:/,
      v: r.message
    )
  )