String Function Calls
1 Introduction
This document describes functions that are used to convert and inspect strings. Note that these functions never change the string itself, they only return a new value.
Strings are surrounded by quotes. If the string contains a quote, it should be escaped by another quote. For example: 'this isn''t funny'
.
For a great deep-dive look into string functions call, check out this video:
2 toLowerCase
Converts all characters in the string to lowercase.
2.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
String to convert | String |
2.2 Output
The output is described in the table below:
Value | Type |
---|---|
The same string, but all lowercase. | String |
2.3 Example
If you use the following input:
|
|
The output is the following:
|
|
3 toUpperCase
Converts all characters in the string to uppercase.
3.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
String to convert | String |
3.2 Output
The output is described in the table below:
Value | Type |
---|---|
The same string, but all uppercase. | String |
3.3 Example
If you use the following input:
|
|
The output is the following:
|
|
4 length
Determines the length of a string.
4.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
String to convert | String |
4.2 Output
The output is described in the table below:
Value | Type |
---|---|
Length of the string | Integer |
4.3 Example
If you use the following input:
|
|
The output is the following:
|
|
5 substring
Retrieves a substring of a string. Note that the first character of a string is located at position '0'
, and the last character is located at position length(string)-1
.
5.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
Subject | String |
Start position of the substring | Integer |
Desired length of the result (optional) | Integer |
5.2 Output
The output is described in the table below:
Value | Type |
---|---|
A part of the original string, starting at the start position with a length equal to the desired length. If no desired length is specified, will return a substring starting at the start position and ending at the end of the string. | String |
5.3 Example
If you use the following input:
|
|
The output is the following:
|
|
If you use a third parameter to specify the desired length of the output:
substring('thisismystring', 6, 2)
The output is the following:
'my'
To prevent the value of the third parameter from getting out of range, you can set a limit to the third parameter, for instance, using the min
and length
functions:
substring('thisismystring', 0, min(length('thisismystring'), 20))
6 find
Finds the position of the first occurrence of the substring in the string.
6.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
Original string, the string that you want to search in | String |
Substring that you want to search for | String |
Start location to begin the search from (optional) | Integer |
6.2 Output
The output is described in the table below:
Value | Type |
---|---|
The first location of the substring in the original string. Will return '-1' if the substring does not occur at all in the original string. |
Integer |
6.3 Example
If you use the following input:
|
|
The output is:
|
|
Substring that doesn’t occur in the original string:
|
|
returns:
|
|
Another example of an input is:
|
|
The output is:
|
|
7 findLast
Finds the position of the last occurrence of a substring in the original string.
7.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
Original string, the string that you want to search in | String |
Substring that you want to search for | String |
Start location to begin the search from (optional) | Integer |
7.2 Output
The output is described in the table below:
Value | Type |
---|---|
The first location of the substring in the original string. Will return '-1' if the substring does not occur at all in the original string. |
Integer |
7.3 Example
If you use the following input:
|
|
The output is:
|
|
Another example of an input where a substring does not occur in the original string:
|
|
The output is:
|
|
An example of an input with the third parameter:
|
|
The output is:
|
|
8 contains
Determines whether the original string (first parameter) contains a substring (second parameter).
For example, this expression:
|
|
is equivalent to the following expression:
|
|
The example below shows searching for an empty variable or empty string, where $param = ''
:
|
|
The input above will return true
.
8.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
Original string, the string that you want to search in | String |
Substring that you want to search for | String |
8.2 Output
The output is described in the table below:
Value | Type |
---|---|
Whether the original string contains the substring. | Boolean |
8.3 Example
If you use the following input:
|
|
The output is:
|
|
9 startsWith
Determines whether a string starts with the specified substring.
9.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
Original string, the string that you want to search in | String |
Substring that you want to search for | String |
9.2 Output
The output is described in the table below:
Value | Type |
---|---|
Whether the original string starts with the substring. | Boolean |
9.3 Example
If you use the following input:
|
|
The output is:
|
|
10 endsWith
Determines whether a string ends with the specified substring.
10.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
Original string, the string that you want to search in | String |
Substring that you want to search for | String |
10.2 Output
The output is described in the table below:
Value | Type |
---|---|
Whether the original string ends with the substring. | Boolean |
10.3 Example
If you use the following input:
|
|
The output is:
|
|
11 trim
Removes all the whitespace at the beginning and end of a string.
11.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
A string | String |
11.2 Output
The output is described in the table below:
Value | Type |
---|---|
Same string but without spaces at the beginning and end. | String |
11.3 Example
If you use the following input:
|
|
The output is:
|
|
12 isMatch
Checks to see if a string matches a given regular expression.
12.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
String to try and match | String |
Regular expression to match | String |
Please note that this function call uses the regular expression language provided by the current platform:
- When used inside a microflow – Java’s regular expressions (for details, see Class Pattern documentation)
- When used in the client – JavaScript’s regular expressions (for details, see Regular Expressions documentation)
12.2 Output
The output is described in the table below:
Value | Type |
---|---|
Whether the string matches or not. | Boolean |
12.3 Example
This input below tests to see whether the string contains only numbers:
|
|
The output is:
|
|
In isMatch()
, the regex is implicitly anchored at ^
and $
.
Other Examples
isMatch('NLG 123.45', '[0-9]')
returnsfalse
isMatch('NLG 123.45', '.*[0-9].*')
returnstrue
NB searching an empty string:
isMatch('', '.*[0-9].*')
returnsfalse
13 replaceAll
Replaces all occurrences of a regular expression with another string.
13.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
The string to search in | String |
The regular expression to match; if you want to search for a literal string, enclose it between \Q and \E (for example, \QPaul S. Mueller\E will search for the string Paul S. Mueller , without interpreting the dot as a wildcard) |
String |
The string to be substituted for each match (this does not support backreferences, substitutions, or captures) | String |
Please note that this function call uses the regular expression language provided by the current platform:
- When used inside microflows – Java’s regular expressions (for details, see Class Pattern)
- When used in the client – JavaScript’s regular expressions (for details, see Regular Expressions)
13.2 Output
The output is described in the table below:
Value | Type |
---|---|
The original string, with all occurrences of the regular expression replaced by the replacement string. If the regular expression does not occur in the string, the original is returned. | String |
13.3 Example
If you use the following input:
|
|
The output is:
|
|
Another example of an input of the following:
|
|
And the output is that there are no matches for the input:
|
|
14 replaceFirst
Replaces the first occurrence of the regular expression with a replacement string.
14.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
The string to search in | String |
The regular expression to match; if you want to search for a literal string, enclose it between \Q and \E (for example, \QPaul S. Mueller\E will search for the string Paul S. Mueller , without interpreting the dot as a wildcard) |
String |
The string to be substituted for each match (this does not support backreferences, substitutions, or captures) | String |
Please note that this function call uses the regular expression language provided by the current platform:
- When used inside a microflow – Java’s regular expressions (for details, see Class Pattern documentation)
- When used in the client – JavaScript’s regular expressions (for details, see Regular Expressions documentation)
14.2 Output
The output is described in the table below:
Value | Type |
---|---|
The original string, with the first occurrence of the regular expression replaced by the replacement string. If the regular expression does not occur in the string, the original is returned. | String |
14.3 Example
If you use the following input:
|
|
The output is:
|
|
15 String Concatenation ( + )
The +
operator can be used to concatenate two strings or a string and a number.
15.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
First parameter | String, integer/long, decimal |
Second parameter | String, integer/long, decimal |
15.2 Output
The output is described in the table below:
Value | Type |
---|---|
A new string that is the literal concatenation of the two input parameters. | String |
15.3 Example
An example of an input to combine two strings can be the following:
|
|
The output is:
|
|
An example of an input to combine a string and a number can be the following:
|
|
The output is:
|
|
16 urlEncode
Converts a string to be used in a URL. This function is useful when you want to use the string as part of the URL.
For example:
|
|
16.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
String to convert | String |
16.2 Output
The output is described in the table below:
Value | Type |
---|---|
The string, URL-encoded. | String |
16.3 Example
If you use the following input:
|
|
The output is:
|
|
17 urlDecode
Converts a string back from a URL. The opposite of urlEncode.
17.1 Input Parameters
The input parameters are described in the table below:
Value | Type |
---|---|
A URL-encoded string to convert | String |
17.2 Output
The output is described in the table below:
Value | Type |
---|---|
The string, URL-decoded. | String |
17.3 Example
If you use the following input:
|
|
The output is:
|
|