strings.strlen() function

The strings.strlen() function returns the length of a string. String length is determined by the number of UTF code points a string contains.

*Output data type: Integer*

  1. import "strings"
  2. strings.strlen(v: "apple")
  3. // returns 5

Parameters

v

The string value to measure.

*Data type: String*

Examples

Filter based on string value length
  1. import "strings"
  2. data
  3. |> filter(fn: (r) => strings.strlen(v: r._measurement) <= 4)
Store the length of string values
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. length: strings.strlen(v: r._value)
  6. })
  7. )