docs-v2/content/flux/v0.x/stdlib/strings/splitaftern.md

1.4 KiB

title description aliases menu weight related introduced
strings.splitAfterN() function The strings.splitAfterN() function splits a string after a specified separator and returns an array of `i` substrings.
/influxdb/v2.0/reference/flux/functions/strings/splitaftern/
/influxdb/v2.0/reference/flux/stdlib/strings/splitaftern/
/influxdb/cloud/reference/flux/stdlib/strings/splitaftern/
flux_0_x_ref
name parent
strings.splitAfterN strings
301
/flux/v0.x/stdlib/strings/split
/flux/v0.x/stdlib/strings/splitafter
/flux/v0.x/stdlib/strings/splitn
0.18.0

The strings.splitAfterN() function splits a string after a specified separator and returns an array of i substrings. Split substrings include the separator t.

Output data type: Array of strings

import "strings"

strings.splitAfterN(v: "a flux of foxes", t: " ", i: 3)

// returns ["a ", "flux ", "of foxes"]

Parameters

v

The string value to split.

t

The string value that acts as the separator.

i

The maximum number of split substrings to return. -1 returns all matching substrings. The last substring is the unsplit remainder.

Examples

Split a string into an array of substrings
import "strings"

data
    |> map (fn:(r) => strings.splitAfterN(v: r.searchTags, t: ","))