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

1.0 KiB

title description aliases menu weight introduced
strings.repeat() function The strings.repeat() function returns a string consisting of `i` copies of a specified string.
/influxdb/v2.0/reference/flux/functions/strings/repeat/
/influxdb/v2.0/reference/flux/stdlib/strings/repeat/
/influxdb/cloud/reference/flux/stdlib/strings/repeat/
flux_0_x_ref
name parent
strings.repeat strings
301 0.18.0

The strings.repeat() function returns a string consisting of i copies of a specified string.

Output data type: String

import "strings"

strings.repeat(v: "ha", i: 3)

// returns "hahaha"

Parameters

v

The string value to repeat.

i

The number of times to repeat v.

Examples

Repeat a string based on existing columns
import "strings"

data
    |> map(fn: (r) => ({
            laugh: r.laugh,
            intensity: r.intensity,
            laughter: strings.repeat(v: r.laugh, i: r.intensity),
        })
    )