Repeats a string 1 or more times.
STRREPEAT("str", n, "sep")
"str" |
- |
A string. The source string. |
n |
- |
An integer. The number of times to repeat the string |
"sep" |
- |
Optional. A string, the separator string. Defaults to "", the empty string. |
A string, the result of replicating str n times.
strrepeat("ABC", 3)
returns "ABCABCABC".
strrepeat("ABC", 3, "+")
returns "ABC+ABC+ABC".
s = "aaa AAA ";
s1 = strrepeat(s, 2);
s2 = s * 2;
Both s1 and s2 contain the string "aaa AAA aaa AAA ".
s1 = "123 ";
s2 = "123 ";
s1 = strrepeat(s1, 5);
s2 *= 5;
Both s1 and s2 contain the string "123 123 123 123 123 ".
STRREPEAT repeats the source string n times.
The * operator also replicates strings. For example:
"String 1" * 3
is equivalent to:
strrepeat("String1", 3)
and yields:
"String1String1String1"
The *= operator repeats a string to an existing string:
s1 = "String 1";
s1 *= 3;
s1 == "String1String1String1"