...
Provides common string function support.
Function | Description | Datatype |
---|
|
|
---|
capitalize(String str) | Capitalizes a String, Changing the first character to title case. | String | Example | {{ StringUtils.capitalize("word") }} | Output | Word |
|
compare(String str1, String str2) | Compare two Strings lexicographically.- Returns -1 when str1 is less than str2.
- Returns 0 when str1 and str2 are equal.
- Returns 1 when str1 is greater than str2.
| int | Example | {% if (StringUtils.compare("lower", "upper") > 0) %} … {% endif %} |
|
compare(String str1, String str2, boolean nullIsLess) | Compare two Strings lexicographically.- Returns -1 when str1 is less than str2.
- Returns 0 when str1 and str2 are equal.
- Returns 1 when str1 is greater than str2.
| int | Example | {% if (StringUtils.compare("lower", "upper", false) > 0) %} … {% endif %} |
|
compareIgnoreCase(String str1, String str2) | Compare two Strings lexicographically, ignoring case differences.- Returns -1 when str1 is less than str2.
- Returns 0 when str1 and str2 are equal.
- Returns 1 when str1 is greater than str2.
| int | Example | {% if (StringUtils.compareIgnoreCase("lower", "upper") > 0) %} … {% endif %} |
|
compareIgnoreCase(String str1, String str2, boolean nullIsLess) | Compare two Strings lexicographically, ignoring case differences.- Returns -1 when str1 is less than str2.
- Returns 0 when str1 and str2 are equal.
- Returns 1 when str1 is greater than str2.
| int | Example | {% if (StringUtils.compareIgnoreCase("lower", "upper", false) > 0) %} … {% endif %} |
|
countMatches(String str, String pattern) | Returns the number of times the pattern appears in the string | int | Example | {{ StringUtils.countMatches("AaaaaaA", "a") }} | Output | 5 |
|
indexOf(String str, String search) | Returns the index (Starts with zero) within the String of the first occurrence of the specified search String. | int | Example | {{ StringUtils.indexOf("abcabcabc", "c") }} | Output | 2 |
|
indexOf(String str, String search, int startPos) | Returns the index (Starts with zero) within the String of the first occurrence of the specified search String starting from the provided zero based index | int | Example | {{ StringUtils.indexOf("abcabcabc", "c", int(4)) }} | Output | 5 |
|
indexOfIgnoreCase(String str, String search) | Returns the case insensitive index (Starts with zero) within the String of the first occurrence of the specified search String. | int | Example | {{ StringUtils.indexOfIgnoreCase("ABCABCABC", "c") }} | Output | 2 |
|
indexOfIgnoreCase(String str, String search, int startPos) | Returns the case insensitive index (Starts with zero) within the String of the first occurrence of the specified search String starting from the provided zero based index. | int | Example | {{ StringUtils.indexOfIgnoreCase("ABCABCABC", "c", int(4)) }} |
|
|
|
isAllLowerCase(String str) | Checks if the String contains only lowercase characters. | boolean | Example | {{ StringUtils.isAllLowerCase("letters") }} {% br %} {{ StringUtils.isAllLowerCase("leTTers") }} | Output | true false |
|
isAllUpperCase(String str) | Checks if the String contains only uppercase characters. | boolean | Example | {{ StringUtils.isAllUpperCase("LETTERS") }} {% br %} {{ StringUtils.isAllUpperCase("leTTers") }} | Output | true false |
|
isAlpha(String str) | Checks if the String contains only unicode letters. | boolean | Example | {{ StringUtils.isAlpha("letters") }}{% br %} {{ StringUtils.isAlpha("Num1") }} | Output | true false |
|
isAlphanumeric(String str) | Checks if the String contains only unicode letters or digits. | boolean | Example | {{ StringUtils.isAlphanumeric("Number3") }}{% br %} {{ StringUtils.isAlphanumeric("Number 3") }} | Output | true false |
|
isAlphanumericSpace(String str) | Checks if the String contains only unicode letters, digits or space. | boolean | Example | {{ StringUtils.isAlphanumericSpace("Number 3") }} | Output | true |
|
isAlphaSpace(String str) | Checks if the string contains only unicode letters or space. | boolean | Example | {{ StringUtils.isAlphaSpace("next letter") }}{% br %} {{ StringUtils.isAlphaSpace("Number 3") }} | Output | true false |
|
isNumeric(String str) | Checks if the String contains only unicode digits. | boolean | Example | {{ StringUtils.isNumeric("123") }}{% br %} {{ StringUtils.isNumeric("Number2") }} | Output | true false |
|
isNumericSpace(String str) | Checks if the String contains only unicode digits or space. | boolean | Example | {{ StringUtils.isNumericSpace("1 2 3") }}{% br %} {{ StringUtils.isNumericSpace("Johnny 5") }} | Output | true false |
|
isWhitespace(String str) | Checks if the String contains only whitespace. | boolean | Example | {{ StringUtils.isWhitespace(" ") }}{% br %} {{ StringUtils.isWhitespace(" letter ") }} | Output | true false |
|
lastIndexOf(String str, String search) | Returns the index (Starts with zero) within the String of the last occurrence of the specified search String. |
|
| Example | {{ StringUtils.lastIndexOf("abcabcabc", "a") }} | Output | 6 |
|
lastIndexOf(String str, String search, int startPos) | Returns the index (Starts with zero) within the String of the last occurrence of the specified search String starting from the provided zero based index. |
|
| Example | {{ StringUtils.lastIndexOf("abcabcabc", "a", int(2)) }} | Output | 0 |
|
lastIndexOfIgnoreCase(String str, String search) | Returns the case insensitive index (Starts with zero) within the String of the last occurrence of the specified search String. | int | Example | {{ StringUtils.lastIndexOfIgnoreCase("ABCABCABC", "a") }} | Output | 6 |
|
lastIndexOf(String str, String search, int startPos) | Returns the case insensitive index (Starts with zero) within the String of the last occurrence of the specified search String starting from the provided zero based index. | int | Example | {{ StringUtils.lastIndexOfIgnoreCase("ABCABCABC", "a", int(2)) }} | Output | 0 |
|
leftPad(String str, int size) | Left pad a String with spaces. | String | Example | T{{ StringUtils.leftPad("1", int(5) }}T | Output | T 1T |
|
repeat(String str, int repeat) | Repeat a String repeat times to form a new String. | String. | Example | {{ StringUtils.repeat("haha", int(5)) }} | Output | hahahahahahahahahaha |
|
repeat(String str, String separator, int repeat) | Repeat a String repeat times to form a new String, with a String separator injected each time. |
|
| Example | {{ StringUtils.repeat("haha", " ", int(5)) }} | Output | haha haha haha haha haha |
|
reverse(String str) | Reverses a String | String | Example | {{ StringUtils.reverse("abcde") }} | Output | edcba |
|
rightPad(String str, int size) | Right pad a String with spaces. | String | Example | T{{ StringUtils.rightPad("1", int(5) }}T | Output | T1 T |
|
splitByCharacterType(String str) | Splits a String into an array of String with each element containing a substring based on the character type. |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bcc49241-03e8-4c17-a234-52731b29243d"><ac:plain-text-body><![CDATA[Character types include: lower case, upper case, numbers, whitespace, math operators | String[] | |
]]></ac:plain-text-body></ac:structured-macro> | {% set array = StringUtils.splitByCharacterType(" AbcdEFG%++-/3432 ") %} Split content:{%- br -%} {%- for item in array -%} {{ item }}{%- br -%} {%- endfor -%} EndSplit | Output | Split content: A bcd EFG % ++ - / 3432 EndSplit |
|
splitByCharacterTypeCamelCase(String str) | Splits a String into an array of String with each element containing a substring based on the character type with the special case to maintain one upper case letter followed by some lower case letters as an element. |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ca9d1dea-004f-4b52-80c5-725c56168808"><ac:plain-text-body><![CDATA[Character types include: lower case, upper case, numbers, whitespace, math operators | String[] | |
]]></ac:plain-text-body></ac:structured-macro> | {% set array = StringUtils.splitByCharacterTypeCamelCase( " AbcdEFGhij%++-/3432 ") %} Split content:{%- br -%} {%- for item in array -%} {{ item }}{%- br -%} {%- endfor -%} EndSplit | Output | Split content: Abcd EF Ghij % ++ - / 3432 EndSplit |
|
swapCase(String str) | Swaps the case of a String changing upper and title case to lower case, and lower case to upper case. | String | Example | {{ StringUtils.swapCase("UPPER lower") }} | Output | upper LOWER |
|
trim(String str) | Removes whitespace from both ends of the String. | String | Example | T{{ StringUtils.trim(" island ") }}T | Output | TislandT |
|
uncapitalize(String str) | Uncapitalizes a String, changing the first character to lower case . | String | Example | {{ StringUtils.uncapitalize("WORD") }} | Output | wORD |
|