strings.substring() function

The strings.substring() function returns a substring based on start and end parameters. These parameters are represent indices of UTF code points in the string.

*Output data type: String*

  1. import "strings"
  2. strings.substring(v: "influx", start: 0, end: 3)
  3. // returns "infl"

Parameters

v

The string value to search.

*Data type: String*

start

The starting index of the substring.

*Data type: Integer*

end

The ending index of the substring.

*Data type: Integer*

Examples

Store the first four characters of a string
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. abbr: strings.substring(v: r.name, start: 0, end: 3)
  6. })
  7. )