{str_repeat:string:times}

Description

Repeats a string a given number of times. The AA counterpart of PHP str_repeat: the first parameter is the text to repeat, the second is how many times to repeat it. The count is read as a whole number, so a non-numeric count counts as zero (empty output) and a count with a leading number like 3px is read as 3. A count of zero returns an empty string. A negative count is not allowed and raises an error, so guard against negative values before you call it. Parameters are not trimmed, so leading or trailing spaces inside the text are kept. Typical uses: drawing a divider line, padding a value, or building a fixed-width spacer.

Parameters

string required default (none)

The text to repeat. Spaces inside the text are kept, since parameters are not trimmed.

times required default (none)

How many times to repeat the string. Read as a whole number, so a non-numeric value counts as zero and a value like 3px is read as 3. Zero gives an empty string; if omitted it counts as zero too. A negative value is not allowed and raises an error.

Examples

test{str_repeat:ab:3}
Expectedababab
Actualababab
Repeats the text ab three times. The result is the three copies joined with nothing between them.
test{str_repeat:=:3px}
Expected===
Actual===
When the count starts with digits and then has other characters, only the leading number is used. Here 3px is read as 3.
test[{str_repeat:=:10}]
Expected[==========]
Actual[==========]
A common use: draw a horizontal divider by repeating a single character. The brackets here only mark the start and end of the output; they are not part of str_repeat.
test[{str_repeat:.:4}]
Expected[....]
Actual[....]
Build a fixed-width run of one character, for example a dotted leader or an indent. A space works the same way, but a run of spaces would be invisible here, so this uses a dot. The brackets are only output markers.
test[{str_repeat:=:{max:0:5}}]
Expected[=====]
Actual[=====]
A negative count is not allowed and raises an error. If the count comes from data that could be negative, clamp it first with max:0:N, which never returns less than zero. Here max:0:5 is 5.
test[{str_repeat:x:abc}]
Expected[]
Actual[]
The count is read as a whole number. A non-numeric count is read as zero, so the output is empty.
test[{str_repeat:x:0}]
Expected[]
Actual[]
A count of zero returns an empty string. The brackets show that nothing is produced between them.