In this Page
String literals function is 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'
Description | Returns a string created by using the specified sequence of Unicode values. This is similar to the JavaScript fromCharCode. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: Eat right |
Description | Returns the string in camelCase. This is similar to the Lodash camelCase. | |
---|---|---|
Syntax |
| |
Example | Expression: $tag.camelCase() where $tag is "sim_world" Result: simWorld |
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 |
| |
Example | Expression: $first.capitalize() where $first contains "JANE" Result: Jane |
Description | Returns the character from a string at the integer-specified location. This is similar to the JavaScript charAt. | |
---|---|---|
Syntax |
| |
Example | Expression: $first.charAt(0) where $first contains John Result: J |
Description | Returns the numeric Unicode value of the character at the given index. This is similar to the JavaScript charCodeAt. | |
---|---|---|
Syntax |
| |
Example | Expression: where $first contains "Dan" Result: 68 |
Description | Combines the text of two or more strings and returns a new string. This is similar to the JavaScript concat. | |
---|---|---|
Syntax |
| |
Example | Expression: where $first contains "John" and $last contains "Doe" Result: JohnDoe Expression: where $first contains "John" and $last contains "Doe" Result: John Doe |
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 includes. | |
---|---|---|
Syntax |
| |
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) |
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 |
| |
Example | Expression: Result: true Expression: Result: true |
Description | Returns the index within the calling This is similar to the JavaScript indexOf. | |
---|---|---|
Syntax |
| |
Example | Expression: where $city is "San Francisco" Result: 0 Expression: where $city is "San Jose" Result: 4 |
Description | Returns the string in kebabCase. This is similar to the Lodash kebabCase. | |
---|---|---|
Syntax |
| |
Example | Expression: $action.kebabCase() where $action is "Check_in" Result: check-in |
Description | Returns the index within the calling This is similar to the JavaScript lastIndexOf. | |
---|---|---|
Syntax |
| |
Example | Expression: $email.lastIndexOf("e") where $email is "vp@example.com" Result: 10 |
Description | Returns the number of code units in the string. This is similar to the JavaScript length. | |
---|---|---|
Syntax |
| |
Example | Expression: $first.length where $first contains John Result: 4 |
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 |
| |
Example | Expression: Result: A negative number. |
Description | Returns the string with the first character in lower case. This is similar to the Lodash lowerFirst. | |
---|---|---|
Syntax |
| |
Example | Expression: $msg.lowerFirst() where $msg is "FOOBAR" Result: fOOBAR |
Description | Returns an array of results when matching a string against a regular expression object. This is similar to the JavaScript match. | |
---|---|---|
Syntax |
| |
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 |
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 |
| |
Example | Expression: $string.repeat ("3") where $string contains "Hello" Result: HelloHelloHello |
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 |
| |
Example |
|
Description | Returns a new string with all matches of a pattern replaced by another. This is similar to the JavaScript replace. | |
---|---|---|
Syntax |
| |
Example | Expression: where $msg contains "All letters" Result: A11 1etters |
Description | Returns the index of the first match of a regular expression object and a string. This is similar to the JavaScript search. | |
---|---|---|
Syntax |
| |
Example | Expression: where $String contains "Four score and seven years ago" Result: 5 |
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 |
| |
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. |
Description | Returns the string in snakeCase. This is similar to the Lodash snakeCase. | |
---|---|---|
Syntax |
| |
Example | Expression: $category.snakeCase() where $category is "LevelCritical" Result: level_critical |
Description | Returns an array of strings divided at the supplied separator. This is similar to the JavaScript split. | ||||
---|---|---|---|---|---|
Syntax |
| ||||
Example | Expression: where $Location contains "/snaplogic/projects/DocTest" Result:
Expression: where $Location contains "/Snaplogic/projects/DocTest" Result:
Expression: where $name contains:
Result:
|
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 |
| |
Example | Where $msg is "hello %s %s" Expression: Result: Where $msg is "hello %2$s %1$s" Expression: Result: |
Description | Returns true or false after determining if one string starts with the characters of another. This is similar to the JavaScript startsWith. | |
---|---|---|
Syntax |
| |
Example | Where $string contains "Copyright 2017" Expression: Result: true Expression: Result: False Expression: Result: true |
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 |
| |
Example | Expression: where $first contains "John" Result: J |
Description | Returns a subset of a This is similar to the JavaScript substring. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: Logic |
Description | Returns the value of the string converted to lower case. This is similar to the JavaScript toLowerCase. | |
---|---|---|
Syntax |
| |
Example | Expression: where $login contains FirstLast@email.com. Result: firstlast@email.com |
Description | Returns the value of the string converted to uppercase. This is similar to the JavaScript toUpperCase. | |
---|---|---|
Syntax |
| |
Example | Expression: where $login contains "FirstLast@email.com". Result: FIRSTLAST@EMAIL.COM |
Description | Returns the string stripped of whitespace from both ends. This is similar to the JavaScript trim. | |
---|---|---|
Syntax |
| |
Example | Expression: where $string contains the string " test " Result: test |
Description | Returns the string stripped of whitespace from the left end of the string. This is similar to the JavaScript trimLeft. | |
---|---|---|
Syntax |
| |
Example | Expression: where $string contains the string " test" Result: test |
Description | Returns the string stripped of whitespace from the right end of the string. |
---|---|
Syntax | |
Example | Expression: where $string contains the string "test " Result: test |
Description | Returns the string with the first character in upper case. This is similar to the Lodash upperFirst. | |
---|---|---|
Syntax |
| |
Example | Expression: $msg.upperFirst() where $msg is "foobar" Result: Foobar |
Checking for a Non-empty String
|
Checking for an Existing Value
|
Checking for a Non-empty String and an Existing Value
|
Creating an Email Address from First Initial, Last Name
|