docs-v2/content/influxdb/cloud/reference/flux/stdlib/strings/hasprefix.md

899 B

title description aliases menu weight related
strings.hasPrefix() function The strings.hasPrefix() function indicates if a string begins with a specific prefix.
/influxdb/cloud/reference/flux/functions/strings/hasprefix/
influxdb_cloud_ref
name parent
strings.hasPrefix Strings
301
/influxdb/cloud/reference/flux/stdlib/strings/hassuffix

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

Output data type: Boolean

import "strings"

strings.hasPrefix(v: "go gopher", prefix: "go")

// 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
import "strings"

data
  |> filter(fn:(r) => strings.hasPrefix(v: r.metric, prefix: "int_" ))