text.repeat

Description

Repeats a string a specified number of times.

Syntax

flex.text.repeat(string, count)

Parameters

Parameter Type Required Description
string string Yes The string to repeat
count number Yes The number of times to repeat the string

Returns

Type: string

A new string consisting of the input string repeated the specified number of times. Returns null if input is null.

Examples

Example 1: Basic Repetition

RETURN flex.text.repeat('Ha', 3) AS result

Output:

result
------
HaHaHa

Example 2: Creating Separators

RETURN flex.text.repeat('-', 40) AS separator

Output:

separator
----------------------------------------
----------------------------------------

Example 3: Building Star Ratings

MATCH (r:Review)
RETURN r.product, flex.text.repeat('★', r.rating) AS stars

Output:

product     | stars
------------|-------
Laptop      | ★★★★★
Mouse       | ★★★★
Keyboard    | ★★★

Example 4: Indentation

WITH 2 AS level
RETURN flex.text.repeat('  ', level) + 'Nested Item' AS indented

Output:

indented
----------------
    Nested Item

Notes

  • Returns null if input is null
  • Count must be a non-negative integer
  • Useful for creating visual elements, separators, or formatting
  • Can be combined with other text functions for complex formatting

See Also

Frequently Asked Questions 2
What does flex.text.repeat return if count is 0?

It returns an empty string ''.

Can I repeat multi-character strings?

Yes. The function repeats the entire input string, not just a single character. For example, flex.text.repeat('Ha', 3) returns 'HaHaHa'.