-
Notifications
You must be signed in to change notification settings - Fork 1
String functions
Converts a string to camel case.
camel("This is-a_STRING") //result: "thisIsAString"
Concatenates the elements passed to as arguments into a string. The function supports concatenation of strings and numbers.
concat("{id:", 123, "}") //result: "{id:123}"
Note: String concatenation can also be achieved using the Addition operator (+), provided that all arguments are string variables or literals. For example: "a" + "b"
Returns 1 (true) if the string received in the 1st parameter ends with the suffix specified in the 2nd parameter (case-sensitive).
endsWith("abcdef", "def") //result: 1.0
Returns the first match of the given regular expression found inside a string.
findMatch("user@domain.com", "(?<=@)[^.]+(?=\.)") //result: "domain"
Returns a list containing all matches of the given regular expression found inside a string.
findMatches("Sample tweet #java #jep", "([#][A-z]+)") //result: ["#java", "#jep"]
Returns a formatted string according to given pattern and variable arguments.
formatString("%s=%.0f", "test", 2.0) //result: "test=2"
Left-pads a given string to the given size with white-spaces or a custom padding string.
leftPad("123", 5) //result: " 123"
leftPad("123", 5, "0") //result: "00123"
Note: Also achievable using the alias:
lpad
Converts a text string to all lower-case letters.
lower("STRING") //result: "string"
Note: Also achievable using the alias:
lcase
Returns a 1 (true) if the given string contains at least one match of the given regular expression or 0 (false) if not.
matches("user@domain.com", "(?<=@)[^.]+(?=\.)") //result: 1.0
Normalizes a Unicode string, replacing accents and other diacritics with ASCII characters.
normalizeString("ações") //result: "acoes"
Converts a string to proper case: the first letter in each word to upper-case, and all other letter to lower-case.
proper("good DAY!") //result: "Good Day!"
Returns a new string after replacing all occurrences of the search criteria within the original string with the replacement argument.
replace("foo-boo", "oo", "ee") //result: "fee-bee"
Returns a new string after replacing all matches of the given regular expression with the replacement argument.
replaceRegex("file1.json", "(\\.\\w+$)", "") //result: "file1"
Right-pads a given string to the given size with white-spaces or a custom padding string.
rightPad("abc", 5) //result: "abc "
rightPad("abc", 5, ".") //result: "abc.."
Note: Also achievable using the alias:
rpad
Splits a string into a string array based on a separating string or regular expression.
split("do-re-mi", "-") //result: ["do", "re", "mi"]
split("192.168.0.1/24", "[.\\/]") //result: ["192", "168", "0", "1", "24"]
Returns 1 (true) if the string received in the 1st parameter starts with the prefix specified in the 2nd parameter (case-sensitive).
startsWith("abcdef", "abc") //result: 1.0
Removes leading and trailing spaces.
trim(" string ") //result: "string"
Converts a text string to all upper-case letters.
upper("string") //result: "STRING"
Note: Also achievable using the alias:
ucase