Documentation

strings.repeat() function

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),
        })
    )

Was this page helpful?

Thank you for your feedback!


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.