regexp.findStringIndex() function
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]
Parameters
r
The regular expression used to search v
.
v
The string value to search.
Examples
Index the bounds of first regular expression match in each row
import "regexp"
data
|> map(fn: (r) => ({r with
regexStr: r.regexStr,
_value: r._value,
matchIndex: regexp.findStringIndex(
r: regexp.compile(r.regexStr),
v: r._value
)
})
)
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.