regexp.findStringIndex() function

Warning! This page documents an earlier version of Flux, which is no longer actively developed. Flux v0.65 is the most recent stable version of Flux.

The regexp.findStringIndex() function returns a two-element array of integers defining the beginning and ending indexes of the left-most regular expression match in a string.

Output data type: Array of Integers

import "regexp"

regexp.findStringIndex(r: /ab?/, v: "tablet")

// Returns [1, 3]



The regular expression used to search v.

Data type: Regexp


The string value to search.

Data type: String


Index the bounds of first regular expression match in each row
import "regexp"

  |> map(fn: (r) => ({
      r with
      regexStr: r.regexStr,
      _value: r._value,
      matchIndex: regexp.findStringIndex(
        r: regexp.compile(r.regexStr),
        v: r._value