Back to Function Index
REPEAT()
Overview
REPEAT() repeats the characters in the input string until the specified length is reached. This function is useful for creating patterns, padding strings, or generating repeated sequences of characters.
Function Format
REPEAT(string, length)
Return Value
REPEAT() returns a character string
Examples
REPEAT("APPLE", 10) = "APPLEAPPLE" // Exact repetition
REPEAT("APPLE", 12) = "APPLEAPPLEAP" // Partial repetition
REPEAT("X", 5) = "XXXXX" // Single character
REPEAT("", 5) = "" // Empty string
Notes
Important behaviors:
Repeats the input string until the specified length is reached If the length is less than the input string length, truncates the result If the length is a multiple of the input string length, returns exact repetitions Returns empty string if input string is empty Length must be a positive number Common use cases include:
String padding Pattern generation Visual formatting Data masking Test data generation The function is useful for:
Creating fixed-width strings Generating repeated patterns String manipulation Data formatting
See Also