StringUtil
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.
|
int |
Example |
|
{% if (StringUtils.compare("lower", "upper") > 0) %} |
||||
compare(String str1, String str2, boolean nullIsLess) |
Compare two Strings lexicographically.
|
int |
Example |
|
{% if (StringUtils.compare("lower", "upper", false) > 0) %} |
||||
compareIgnoreCase(String str1, String str2) |
Compare two Strings lexicographically, ignoring case differences.
|
int |
Example |
|
{% if (StringUtils.compareIgnoreCase("lower", "upper") > 0) %} |
||||
compareIgnoreCase(String str1, String str2, boolean nullIsLess) |
Compare two Strings lexicographically, ignoring case differences.
|
int |
Example |
|
{% if (StringUtils.compareIgnoreCase("lower", "upper", false) > 0) %} |
||||
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)) }} |
||||
|
||||
5 |
||||
isAllLowerCase(String str) |
Checks if the String contains only lowercase characters. |
boolean |
Example |
|
{{ StringUtils.isAllLowerCase("letters") }} {% br %} |
||||
Output |
||||
true |
||||
isAllUpperCase(String str) |
Checks if the String contains only uppercase characters. |
boolean |
Example |
|
{{ StringUtils.isAllUpperCase("LETTERS") }} {% br %} |
||||
Output |
||||
true |
||||
isAlpha(String str) |
Checks if the String contains only unicode letters. |
boolean |
Example |
|
{{ StringUtils.isAlpha("letters") }}{% br %} |
||||
Output |
||||
true |
||||
isAlphanumeric(String str) |
Checks if the String contains only unicode letters or digits. |
boolean |
Example |
|
{{ StringUtils.isAlphanumeric("Number3") }}{% br %} |
||||
Output |
||||
true |
||||
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 %} |
||||
Output |
||||
true |
||||
isNumeric(String str) |
Checks if the String contains only unicode digits. |
boolean |
Example |
|
{{ StringUtils.isNumeric("123") }}{% br %} |
||||
Output |
||||
true |
||||
isNumericSpace(String str) |
Checks if the String contains only unicode digits or space. |
boolean |
Example |
|
{{ StringUtils.isNumericSpace("1 2 3") }}{% br %} |
||||
Output |
||||
true |
||||
isWhitespace(String str) |
Checks if the String contains only whitespace. |
boolean |
Example |
|
{{ StringUtils.isWhitespace(" ") }}{% br %} |
||||
Output |
||||
true |
||||
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. |
String[] |
Example |
]]></ac:plain-text-body></ac:structured-macro> |
{% set array = StringUtils.splitByCharacterType(" |
||||
Output |
||||
Split content:
|
||||
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. |
String[] |
Example |
]]></ac:plain-text-body></ac:structured-macro> |
{% set array = StringUtils.splitByCharacterTypeCamelCase( |
||||
Output |
||||
Split content:
|
||||
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 |
||||