docs-v2/content/v2.0/reference/flux/functions/regexp/findstring.md

932 B

title description menu weight related
regexp.findString() function The `regexp.findString()` function returns the left-most regular expression match in a string.
v2_0_ref
name parent
regexp.findString Regular expressions
301
/v2.0/reference/flux/functions/regexp/splitregexp

The regexp.findString() function returns the left-most regular expression match in a string.

Output data type: String

import "regexp"

findString(r: /foo.?/, v: "seafood fool")

// Returns "food"

Parameters

r

The regular expression used to search v.

Data type: Regexp

v

The string value to search.

Data type: String

Examples

Find the first regular expression match in each row
import "regexp"

data
  |> map(fn: (r) => ({
      r with
      message: r.message,
      regexp: r.regexp,
      match: regexp.findString(r: r.regexp, v: r.message)
    })
  )