General strings functions and functions for searching in strings are described separately.Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The documentation below is generated from the
system.functions system table.format
Introduced in: v20.1.0 Format thepattern string with the values (strings, integers, etc.) listed in the arguments, similar to formatting in Python.
The pattern string can contain replacement fields surrounded by curly braces {}.
Anything not contained in braces is considered literal text and copied verbatim into the output.
Literal brace character can be escaped by two braces: {{ and }}.
Field names can be numbers (starting from zero) or empty (then they are implicitly given monotonically increasing numbers).
Syntax
pattern— The format string containing placeholders.Strings0[, s1, ...]— One or more values to substitute into the pattern.Any
String
Examples
Numbered placeholders
Query
Response
Query
Response
overlay
Introduced in: v24.9.0 Replaces part of the stringinput with another string replace, starting at the 1-based index offset.
Syntax
s— The input string.Stringreplace— The replacement stringconst Stringoffset— An integer typeInt(1-based). Ifoffsetis negative, it is counted from the end of the strings.Intlength— Optional. An integer typeInt.lengthspecifies the length of the snippet within the input stringsto be replaced. Iflengthis not specified, the number of bytes removed fromsequals the length ofreplace; otherwiselengthbytes are removed.Int
String
Examples
Basic replacement
Query
Response
Query
Response
overlayUTF8
Introduced in: v24.9.0 Replace part of the strings with another string replace, starting at the 1-based index offset.
Assumes that the string contains valid UTF-8 encoded text.
If this assumption is violated, no exception is thrown and the result is undefined.
Syntax
s— The input string.Stringreplace— The replacement string.const Stringoffset— An integer typeInt(1-based). Ifoffsetis negative, it is counted from the end of the input strings.(U)Int*length— Optional. Specifies the length of the snippet within the input stringsto be replaced. Iflengthis not specified, the number of characters removed fromsequals the length ofreplace, otherwiselengthcharacters are removed.(U)Int*
String
Examples
UTF-8 replacement
Query
Response
printf
Introduced in: v24.8.0 Theprintf function formats the given string with the values (strings, integers, floating-points etc.) listed in the arguments, similar to printf function in C++.
The format string can contain format specifiers starting with % character.
Anything not contained in % and the following format specifier is considered literal text and copied verbatim into the output.
Literal % character can be escaped by %%.
The format string can be either a constant or a column expression, allowing different format patterns per row.
Syntax
format— The format string with%specifiers.Stringsub1, sub2, ...— Optional. Zero or more values to substitute into the format string.Any
String
Examples
C++-style formatting
Query
Response
regexpQuoteMeta
Introduced in: v20.1.0 Adds a backslash before these characters with special meaning in regular expressions:\0, \\, |, (, ), ^, $, ., [, ], ?, *, +, {, :, -.
This implementation slightly differs from re2::RE2::QuoteMeta.
It escapes zero byte as \0 instead of \x00 and it escapes only required characters.
Syntax
s— The input string containing characters to be escaped for regex.String
String
Examples
Escape regex special characters
Query
Response
replaceAll
Introduced in: v1.1.0 Replaces all occurrences of the substringpattern in haystack by the replacement string.
Syntax
replace
Arguments
haystack— The input string to search in.Stringpattern— The substring to find and replace.const Stringreplacement— The string to replace the pattern with.const String
String
Examples
Replace all occurrences
Query
Response
replaceOne
Introduced in: v1.1.0 Replaces the first occurrence of the substringpattern in haystack by the replacement string.
Syntax
haystack— The input string to search in.Stringpattern— The substring to find and replace.const Stringreplacement— The string to replace the pattern with.const String
String
Examples
Replace first occurrence
Query
Response
replaceRegexpAll
Introduced in: v1.1.0 LikereplaceRegexpOne but replaces all occurrences of the pattern.
As an exception, if a regular expression worked on an empty substring, the replacement is not made more than once.
Syntax
REGEXP_REPLACE
Arguments
haystack— The input string to search in.Stringpattern— The regular expression pattern to find.const Stringreplacement— The string to replace the pattern with, may contain substitutions.const String
String
Examples
Replace all characters with doubled version
Query
Response
Query
Response
replaceRegexpOne
Introduced in: v1.1.0 Replaces the first occurrence of the substring matching the regular expressionpattern (in re2 syntax) in haystack by the replacement string.
replacement can contain substitutions \0-\9.
Substitutions \1-\9 correspond to the 1st to 9th capturing group (submatch), substitution \0 corresponds to the entire match.
To use a verbatim \ character in the pattern or replacement strings, escape it using \.
Also keep in mind that string literals require extra escaping.
Syntax
haystack— The input string to search in.Stringpattern— The regular expression pattern to find.const Stringreplacement— The string to replace the pattern with, may contain substitutions.const String
String
Examples
Converting ISO dates to American format
Query
Response
Query
Response
translate
Introduced in: v22.7.0 Replaces characters in the strings using a one-to-one character mapping defined by from and to strings.
from and to must be constant ASCII strings.
If from and to have equal sizes, each occurrence of the first character of first in s is replaced by the first character of to, the second character of first in s is replaced by the second character of to, etc.
If from contains more characters than to, all occurrences of the characters at the end of from that have no corresponding character in to are deleted from s.
Non-ASCII characters in s are not modified by the function.
Syntax
s— The input string to translate.Stringfrom— A constant ASCII string containing characters to replace.const Stringto— A constant ASCII string containing replacement characters.const String
String
Examples
Character mapping
Query
Response
Query
Response
translateUTF8
Introduced in: v22.7.0 Liketranslate but assumes s, from and to are UTF-8 encoded strings.
Syntax
s— UTF-8 input string to translate.Stringfrom— A constant UTF-8 string containing characters to replace.const Stringto— A constant UTF-8 string containing replacement characters.const String
String data type value. String
Examples
UTF-8 character translation
Query
Response