String Functions
Scalar functions for string processing and manipulation that can be used in any expression context.
replace(string, pattern)
Replaces all occurrences of a pattern in a string.
Parameters
- string - String expression to search within
- pattern - String expression representing the text to replace
Description
The replace() function removes all occurrences of the specified pattern from
the input string. This function performs literal string replacement, not
pattern matching. If the pattern is not found, the original string is returned
unchanged.
starts_with(string, prefix)
Tests whether a string starts with a specified prefix.
Parameters
- string - String expression to test
- prefix - String expression representing the prefix to check for
Description
The starts_with() function returns true if the input string begins with the
specified prefix, false otherwise. The comparison is case-sensitive. An empty
prefix will always return true for any string.
ends_with(string, suffix)
Tests whether a string ends with a specified suffix.
Parameters
- string - String expression to test
- suffix - String expression representing the suffix to check for
Description
The ends_with() function returns true if the input string ends with the
specified suffix, false otherwise. The comparison is case-sensitive. An empty
suffix will always return true for any string.
contains(string, substring)
Tests whether a string contains a specified substring.
Parameters
- string - String expression to search within
- substring - String expression representing the text to search for
Description
The contains() function returns true if the input string contains the
specified substring anywhere within it, false otherwise. The comparison is
case-sensitive. An empty substring will always return true for any string.
lower(string)
Converts a string to lowercase.
Parameters
- string - String expression to convert
Description
The lower() function converts all uppercase characters in the input string
to their lowercase equivalents. Characters that are already lowercase or
non-alphabetic characters remain unchanged.
upper(string)
Converts a string to uppercase.
Parameters
- string - String expression to convert
Description
The upper() function converts all lowercase characters in the input string
to their uppercase equivalents. Characters that are already uppercase or
non-alphabetic characters remain unchanged.
url_encode(string)
Encodes a string for safe use in URL query parameters (application/x-www-form-urlencoded style).
Parameters
- string - String expression to encode
Description
The url_encode() function escapes characters so the value can be used in URL
query parameter names and values. Alphanumeric characters and .-*_ are left
unchanged; ASCII space is encoded as +; all other bytes are encoded as %XX
using uppercase hexadecimal UTF-8 byte values.
url_decode(string)
Decodes a URL-encoded string (inverse of url_encode).
Parameters
- string - String expression to decode
Description
The url_decode() function reverses url_encode(): + is decoded to space,
%XX sequences are decoded to their byte values, and the result is interpreted
as UTF-8. Invalid encodings may produce an error depending on the execution engine.
substr(string, start, end)
Returns a substring from start index to end index (exclusive).
Parameters
- string - String expression to extract from
- start - Integer expression for the starting index (0-based, supports negative indices)
- end - Integer expression for the ending index (exclusive, supports negative indices)
Description
The substr() function returns a new string containing characters from the start
index up to but not including the end index. Both indices are 0-based and support
negative values, where -1 refers to the last character, -2 to the second-last, and
so on. If start is greater than or equal to end, an empty string is returned. The
function handles out-of-bounds indices gracefully by clamping them to valid string
boundaries.
uuid()
Generates a random UUID v4 string.
Parameters
This function takes no parameters.
Description
The uuid() function returns a new random UUID (universally
unique identifier) string each time you call it. The generated
value follows the UUID v4 format (e.g.,
"550e8400-e29b-41d4-a716-446655440000"). Each invocation
produces a different value.
uuid5(name)
Generates a deterministic UUID v5 string (RFC 4122).
Parameters
- name - String expression to derive the UUID from
Description
The uuid5() function returns a deterministic UUID (universally unique
identifier) string derived from the input name. The generated value follows the
UUID v5 format (e.g., xxxxxxxx-xxxx-5xxx-8xxx-xxxxxxxxxxxx). The same input
always produces the same output.
len(string)
Returns the length of a string in characters.
Parameters
- string - String expression to measure
Description
The len() function returns the number of characters in the input string.
This counts Unicode characters, not bytes, so multi-byte characters are
counted as single characters. An empty string returns 0.