strings.index() function
The strings.index()
function returns the index of the first instance of a substring
in a string. If the substring is not present, it returns -1
.
Output data type: Integer
import "strings"
strings.index(v: "go gopher", substr: "go")
// returns 0
Parameters
v
The string value to search.
substr
The substring to search for.
Examples
Find the first occurrence of a substring
import "strings"
data
|> map(fn: (r) => ({r with the_index: strings.index(v: r.pageTitle, substr: "the")}))
Was this page helpful?
Thank you for your feedback!
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, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.