strings.hasPrefix() function

The strings.hasPrefix() function indicates if a string begins with a specified prefix.

*Output data type: Boolean*

  1. import "strings"
  2. strings.hasPrefix(v: "go gopher", prefix: "go")
  3. // returns true

Parameters

v

The string value to search.

*Data type: String*

prefix

The prefix to search for.

*Data type: String*

Filter based on the presence of a prefix in a column value
  1. import "strings"
  2. data
  3. |> filter(fn:(r) => strings.hasPrefix(v: r.metric, prefix: "int_" ))

Related articles