The REPT function repeats a given string a certain number of times.
This function takes two things as input: a string and a number. It outputs a single string consisting of the input string repeated as many times as the number given.
REPT(string, n) -> repeated_string
string (required, type: string)
The string to repeat.
n (required, type: number)
The number of times to repeat the string.
repeated_string (type: string)
The string created by repeating the input string n times.
The following example takes the string "Hello" and repeats it three times. Note that there is no space (or anything else) between the "Hello"s, because we didn't include that in the input string "Hello":
REPT("Hello", 3) => "HelloHelloHello"
To separate these "Hello"s with spaces, a space must be included in the input string. In the following example, the string "Hello " (with a space at the end) repeats three times. Note that the output string also has a space after the last "Hello":
REPT("Hello ", 3) => "Hello Hello Hello "
The above example hardcoded the input into REPT, but this does not need to be the case. For the last example, assume the formula has access to the following variables:
example_string = "This is a string" example_number = 5
This last example takes the value of example_string ("This is a string") and repeats the number of times indicated in the variable example_number (5).
REPT(example_string, example_number) -> "This is a stringThis is a stringThis is a stringThis is a stringThis is a string"
The function REPT bares many similarities to the function CONCAT: you can think of REPT as a concatenation of n strings that happen to be identical. Like the CONCAT function, REPT does not provide the means to separate the repeated strings by putting some sort of separator string between them. Such functionality is rendered largely redundant by the fact that the desired separator can simply be amended onto the end of the input string (provided it is okay for said separator to also appear at end of the output string.)