In this Page
String Literals
String literals function the similar to JavaScript strings.
A string literal can be constructed with either single quotes or double quotes.
Example:
"Bob" or 'Bob'
The only special characters supported are single quotes or double quotes.
Examples:
"\"Bob\" is a literal string "Bob"
'\'Bob\'' is a literal string 'Bob'
Static Methods
fromCharCode
Description | Returns a string created by using the specified sequence of Unicode values. This is similar to the JavaScript fromCharCode. |
---|---|
Syntax | String.fromCharCode |
Example | Expression: Result: Eat right |
String Functions and Properties
camelCase
Description | Returns the string in camelCase. This is similar to the Lodash camelCase. |
---|---|
Syntax | string.camelCase() |
Example | Expression: $tag.camelCase() where $tag is "sim_world" Result: simWorld |
capitalize
Description | Returns the first character from a string in upper case and the remaining characters in lower case. This is similar to the Lodash capitalize. |
---|---|
Syntax | string.capitalize() |
Example | Expression: $first.capitalize() where $first contains "JANE" Result: Jane |
charAt
Description | Returns the character from a string at the integer-specified location. This is similar to the JavaScript charAt. |
---|---|
Syntax | string.charAt(index) |
Example | Expression: $first.charAt(0) where $first contains John Result: J |
charCodeAt
Description | Returns the numeric Unicode value of the character at the given index. This is similar to the JavaScript charCodeAt. |
---|---|
Syntax | string.charCodeAt(index) |
Example | Expression: where $first contains "Dan" Result: 68 |
concat
Description | Combines the text of two or more strings and returns a new string. This is similar to the JavaScript concat. |
---|---|
Syntax | string.concat(string2[,...]) |
Example | Expression: where $first contains "John" and $last contains "Doe" Result: JohnDoe Expression: where $first contains "John" and $last contains "Doe" Result: John Doe |
contains
Description | Returns true or false after determining if one string can be found within another. If position is specified, the search will begin there. Position defaults to 0. This is similar to the JavaScript contains. |
---|---|
Syntax | $string.contains(searchString[, position]) |
Example | Expression: where $msg contains "Hello, World" Result: true To specify a position in the string where to start searching: Expression: where $msg contains "Hello, World" Result: false (because "Hello" exists before that position) |
endsWith
Description | Returns true or false after determining if one string ends with the characters of another. Optional parameters include This is similar to the JavaScript endsWith |
---|---|
Syntax | string.endsWith() |
Example | Expression: Result: true Expression: Result: true |
indexOf
Description | Returns the index within the calling This is similar to the JavaScript indexOf. |
---|---|
Syntax | string.indexOf(searchValue[, fromIndex]) |
Example | Expression: where $city is "San Francisco" Result: 0 Expression: where $city is "San Jose" Result: 4 |
kebabCase
Description | Returns the string in kebabCase. This is similar to the Lodash kebabCase. |
---|---|
Syntax | string.kebabCase() |
Example | Expression: $action.kebabCase() where $action is "Check_in" Result: check-in |
lastIndexOf
Description | Returns the index within the calling This is similar to the JavaScript lastIndexOf. |
---|---|
Syntax | string.lastIndexOf(searchValue[, fromIndex]) |
Example | Expression: $email.lastIndexOf("x") where $email is "vp@example.com" Result: 4 |
length
Description | Returns the number of code units in the string. This is similar to the JavaScript length. |
---|---|
Syntax | string.length |
Example | Expression: $first.length where $first contains John Result: 4 |
localeCompare
Description | Compares this string to another and returns a number that represents the sort order. The meaning of the number is as follows:
This is similar to the JavaScript String.localeCompare method. |
---|---|
Syntax | string.localeCompare(compareString) |
Example | Expression: Result: A negative number. |
lowerFirst
Description | Returns the string with the first character in lower case. This is similar to the Lodash lowerFirst. |
---|---|
Syntax | string.lowerFirst() |
Example | Expression: $msg.lowerFirst() where $msg is "FOOBAR" Result: fOOBAR |
match
Description | Returns an array of results when matching a string against a regular expression object. This is similar to the JavaScript match. |
---|---|
Syntax | string.match(regexp) |
Example | The argument to match() takes a string that will be interpreted as a regular expression. This enables you to create expressions such as the following to perform a global search to match strings in the employee code that contain actual employee ID values, followed by any five digits: To match a whole word in a given variable called FirstName: Expression: $FirstName.match(/\bJohn\b/g) where \b sets the word boundary and looks for string 'John' in the incoming string variable called $FirstName Result: John |
repeat
Description | Returns a new string containing the specified number of copies of the specified string, concatenated together. This is similar to the JavaScript repeat. |
---|---|
Syntax | string.repeat(number) |
Example | Expression: $string.repeat ("3") where $string contains "Hello" Result: HelloHelloHello |
replace
Description | Returns a new string with some or all matches of a pattern replaced by another. The replacement can be a string or a function that is called for each match. If the first argument is a regular expression, the method will replace all matches if the global flag is set (e.g. /test/g). If the global flag is not set or the first argument is a string, only the first match will be replaced. If the replacement is a function, its result will be used as the replacement for a given match. The function will be passed the following parameters:
This is similar to the JavaScript replace. | |
---|---|---|
Syntax | string.replace(find,replaceWith) | |
Example |
|
replaceAll
Description | Returns a new string with all matches of a pattern replaced by another. This is similar to the JavaScript replace. |
---|---|
Syntax | string.replaceAll(find,replaceWith) |
Example | Expression: where $msg contains "All letters" Result: A11 1etters |
search
Description | Returns the index of the first match of a regular expression object and a string. This is similar to the JavaScript search. |
---|---|
Syntax | string.search(regex) |
Example | Expression: where $String contains "Four score and seven years ago" Result: 5 |
slice
Description | Returns a new string with text extracted from another string. If beginIndex is greater than or equal to the length of the string, an empty string is returned. If it is negative, it returns that many characters from the end of the string length. If This is similar to the JavaScript slice. |
---|---|
Syntax | string.slice(beginIndex[, endIndex]) |
Example | Where $String contains "Copyright 2017 All rights reserved." Expression: $String.slice(10) Result: 2017 All rights reserved. Expression: $String.slice(10,14) Result: 2017 Expression: $String.slice(10,-2) Result: 2017 All rights reserve Expression: $String.slice(-2) Result: d. |
snakeCase
Description | Returns the string in snakeCase. This is similar to the Lodash snakeCase. |
---|---|
Syntax | string.snakeCase() |
Example | Expression: $category.snakeCase() where $category is "LevelCritical" Result: level_critical |
split
Description | Returns an array of strings divided at the supplied separator. This is similar to the JavaScript split. |
---|---|
Syntax | string.split(separator[,limit]) To split at a newline character, use |
Example | Expression: where $Location contains "/snaplogic/projects/DocTest" Result: [ "", "snaplogic", "projects", "DocTest" ] Expression: where $Location contains "/Snaplogic/projects/DocTest" Result: [ "", "Snaplogic", "projects" ] Expression: where $name contains: where $name contains: [{, ...}, {name:John Jones}] {name:John Paul Jones} name: "John Paul Jones" {name:John Jones} name: "John Jones" Result: [{, ...}, {, ...}] {name:{, ...}} name: [John, Paul, Jones] "John", "Paul", "Jones" {name:[John, Jones]} name: [John, Jones] "John", "Jones" |
sprintf
Description | Swaps out a part of the string using placeholders with another. This is similar to JavaScript sprintf() but includes extended functionality as described in java.util class formatter. |
---|---|
Syntax | string.sprintf() |
Example | Where $msg is "hello %s %s" Expression: Result: Where $msg is "hello %2$s %1$s" Expression: Result: |
startsWith
Description | Returns true or false after determining if one string starts with the characters of another. This is similar to the JavaScript startsWith. |
---|---|
Syntax | string.startsWith(searchString[,position]) |
Example | Where $string contains "Copyright 2017" Expression: Result: true Expression: Result: False Expression: Result: true |
substr
Description | Returns the characters in a string beginning at the specified location through the specified number of characters. This is similar to the JavaScript substr. |
---|---|
Syntax | string.substr(start[,length]) |
Example | Expression: where $first contains "John" Result: J |
substring
Description | Returns a subset of a This is similar to the JavaScript substring. |
---|---|
Syntax | string.substring(start[,end]) |
Example | Expression: Result: Logic |
toLowerCase
Description | Returns the value of the string converted to lower case. This is similar to the JavaScript toLowerCase. |
---|---|
Syntax | string.toLowerCase() |
Example | Expression: where $login contains FirstLast@email.com. Result: firstlast@email.com |
toUpperCase
Description | Returns the value of the string converted to uppercase. This is similar to the JavaScript toUpperCase. |
---|---|
Syntax | string.toUpperCase() |
Example | Expression: where $login contains "FirstLast@email.com". Result: FIRSTLAST@EMAIL.COM |
trim
Description | Returns the string stripped of whitespace from both ends. This is similar to the JavaScript trim. |
---|---|
Syntax | string.trim() |
Example | Expression: where $string contains the string " test " Result: test |
trimLeft
Description | Returns the string stripped of whitespace from the left end of the string. This is similar to the JavaScript trimLeft. |
---|---|
Syntax | string.trimLeft() |
Example | Expression: where $string contains the string " test" Result: test |
trimRight
Description | Returns the string stripped of whitespace from the right end of the string. |
---|---|
Syntax | This is similar to the JavaScript trimRight. string.trimRight() |
Example | Expression: where $string contains the string "test " Result: test |
upperFirst
Description | Returns the string with the first character in upper case. This is similar to the Lodash upperFirst. |
---|---|
Syntax | string.upperFirst() |
Example | Expression: $msg.upperFirst() where $msg is "foobar" Result: Foobar |