String Functions
String Functions
| Function | Description |
|---|---|
| concatenate(str1, str2,…) | Joins several values in one text string. |
| contains(String str, char searchChar) | Checks if String contains a search character, handling null. |
| contains(String str, String searchStr) | Checks if String contains a search String, handling null. |
| containsAny(String str, char[] chars) | Checks if the String contains any character in the given set of characters. |
| containsAny(String str, String searchChars) | Checks if the String contains any character in the given set of characters. |
| endsWith(String str, String suffix) | Check if a String ends with a specified suffix. |
| format(Number num) | Converts a number into a string with two decimals and the digits grouped by a comma, for example, 1234.5 -> 1,234.50. The same as toString(num, “#,##0.00”). |
| format(Number num, String format) | The same as toString(Number num, String format). |
| isEmpty(String str) | Checks if a String is null, empty (“”), or blank, that is, of spaces, tabs or line breaks only. |
| isNotEmpty(String str) | The opposite of isEmpty: checks if a String has a character other than a space, tab or line break. |
| isNumeric(String str) | Checks whether the string represents a number. Returns false for a null, empty, or blank string. |
| length(String str) | Returns the number of characters in a string. |
| like(String str, String pattern) | Used to check whether a string value matches the predefined pattern, such as emails, phone numbers, and zip codes. For more information, see Pattern-Matching Function. |
| lowerCase(String str) | Converts a String to lower case. |
| removeEnd(String str, String remove) | Removes a substring only if it is at the end of a source string, otherwise returns the source string. |
| removeStart(String str, String remove) | Removes a substring only if it is at the beginning of a source string, otherwise returns the source string. |
| replace(String str, String searchString, String replacement) |
Replaces all occurrences of a String within another String. |
| replace(String str, String searchString, String replacement, int max) |
Replaces a String with another String inside a larger String, for the first max values of the search String. |
| startsWith(String str, String prefix) | Check if a String starts with a specified prefix. |
| substr(String str, int pos, int length) | Gets a substring of the specified length that starts at the given zero-based position. Returns an empty string if the position is beyond the end of the String. |
| substring(String str, int beginIndex) | Gets a substring from the specified String. A negative start position can be used to start n characters from the end of the String. |
| substring(String str, int beginIndex, int endIndex) | Gets a substring from the specified String. A negative start position can be used to start or end n characters from the end of the String. |
| textJoin (String separator, Object[]) | Combines non-empty values from multiple ranges and strings and includes a separator between each two values combined into single text. Objects can be of any type, such as string, double, integer, and custom type. |
| textSplit (String separator, String text) | Splits the text at every whole separator, found from left to right, into an array of the non-empty parts. An empty text gives an empty array, and a null text gives null. The separator is plain text, not a pattern. A null or empty separator, like a separator that the text does not contain, gives the whole non-empty text as the only part. For example, textSplit(“, “, “a,, b”) -> [“a,”, “b”]. |
| toBoolean(a) | Converts a string to Boolean. |
| toDouble(String) | Converts a string of numeric characters to the Double. The dot “.” symbol must be used as a decimal separator. |
| toInteger(String) | Converts a string of numeric characters to the Integer value. |
| toNumber(String) | Converts a string of numeric characters to a Number, using the US locale format. Returns null if the string is empty, blank, or cannot be fully parsed as a number. |
| toString(Number num) | Converts a number into a string with all its digits and without an exponent. Trailing zeroes after the decimal point are omitted, for example, 1234.5678 -> 1234.5678 and 1000.0 -> 1000. To round a number, use toString(Number num, String format). |
| toString(Number num, String format) | Converts a number into a string according to the specified format as follows: 0 Used as a digit. # Used as a digit. Meaningless zeroes are omitted, for example, 012.300 -> 12.3. . Used as a decimal separator or monetary decimal separator. - Used as a minus sign. , Separates items in a group. E Separates the mantissa and exponent in a scientific notation. It does not need to be quoted in a prefix or suffix. ; Separates positive and negative subpatterns. % Used to multiply the value by 100 and display it as percentage. ‰ Used to multiply the value by 1000 and display it as a milli-value. ’ Used to quote special characters in a prefix or suffix. Example: “’#’#” formats 123 to “#123”. To create a single quote, use two symbols in a row: “# o’‘clock”. |
| toString(Object value) | Converts a value into a string. An array is written as its elements in square brackets, separated by a comma and a space, for example, [1, 2, 3]. An array inside an array is written in its own brackets, as in [[1, 2], [3]], a date in the ISO form yyyy-MM-dd, as in [2024-01-15], and an empty element as null. |
| trim(String str) | Removes whitespace characters from both ends of a string. |
| upperCase(String str) | Converts a string to upper case. |