ModelWorks logoModelWorks
JSON TransformString

repeat

Repeat a string a fixed number of times

repeat

Returns the string repeated count times, end-to-end.

Options

OptionTypeRequiredDefaultDescription
countintegerYesNumber of repetitions (must be ≥ 0).

Example

Input

JSON
"ab"

Operation

JSON
{ "type": "repeat", "options": { "count": 3 } }

Output

JSON
"ababab"

In a Circuit Step

JSON
{
  "name": "build_separator_line",
  "description": "Build a separator line by repeating a single character",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ input.divider_char }}",
    "operations": [
      { "type": "repeat", "options": { "count": 40 } }
    ]
  },
  "outputs": [
    {
      "name": "separator_line",
      "description": "Divider character repeated 40 times",
      "value": "${{ build_separator_line.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with repeat: expected string if the input is not a string.
  • count: 0 returns an empty string "".
  • Very large count values can blow memory — Rust's String::repeat will panic on capacity overflow.
  • For "join with separator" semantics, use join over an array instead.
On this page

On this page