Documentation

strings.lastIndexAny() function

The strings.lastIndexAny() function returns the index of the last instance of any specified characters in a string. If none of the specified characters are present, the function returns -1.

Output data type: Integer

import "strings"

strings.lastIndexAny(v: "chicken", chars: "aeiouy")

// returns 5

Parameters

v

The string value to search.

Data type: String

chars

Characters to search for.

Data type: String

Examples

Find the last occurrence of characters from a string
import "strings"

data
  |> map(fn: (r) => ({
      r with
      charLastIndex: strings.lastIndexAny(v: r._field, chars: "_-")
    })
  )

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: