regexp.findString() function

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

*Output data type: String*

  1. import "regexp"
  2. findString(r: /foo.?/, v: "seafood fool")
  3. // 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
  1. import "regexp"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. message: r.message,
  6. regexp: r.regexp,
  7. match: regexp.findString(r: r.regexp, v: r.message)
  8. })
  9. )

Related articles