API Docs - v4.0.6
Str
charAt (Function)
Returns the char value as a string value at the specified index.
Syntax
<STRING> str:charAt(<STRING> input.value, <INT> index)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.value | The input string that used to find the character. | STRING | No | No | |
index | The variable that specifies the index. | INT | No | No |
Examples EXAMPLE 1
charAt("WSO2", 1)
This will output the character that exists at index 1. In this case, it will output 'S'.
coalesce (Function)
Returns the value of the first of its input parameters that is not null
Syntax
<INT|LONG|DOUBLE|FLOAT|STRING|BOOL|OBJECT> str:coalesce(<INT|LONG|DOUBLE|FLOAT|STRING|BOOL|OBJECT> argn)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
argn | It can have one or more input parameters in any data type. All the specified parameters should be of the same type. | INT LONG DOUBLE FLOAT STRING BOOL OBJECT |
No | No |
Examples EXAMPLE 1
coalesce(null, "BBB", "CCC")
This returns the first input parameter that is not null. In this example, it returns "BBB"
concat (Function)
Returns a string that is the result of concatenating two or more string values.
Syntax
<STRING> str:concat(<STRING> argn)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
argn | It can have two or more string type input parameters. |
STRING | No | No |
Examples EXAMPLE 1
concat("D533", "8JU^", "XYZ")
This returns a string value by concatenating the given arguments. In this case, it will return "D5338JU^XYZ" as the output
contains (Function)
This method returns true
if theinput.string
contains the specified sequence of char values in the search.string
.
Syntax
<BOOL> str:contains(<STRING> input.string, <STRING> search.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | Input string value. | STRING | No | No | |
search.string | The string value to be searched for in the input.string . |
STRING | No | No |
Examples EXAMPLE 1
contains("21 products are produced by WSO2 currently", "WSO2")
This returns a boolean value as the output. In this case, it returnstrue
.
equalsIgnoreCase (Function)
Compares two strings lexicographically.
Syntax
<BOOL> str:equalsIgnoreCase(<STRING> arg1, <STRING> arg2)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
arg1 | The first input string argument. | STRING | No | No | |
arg2 | The second input string argument. This is compared with the first argument. | STRING | No | No |
Examples EXAMPLE 1
equalsIgnoreCase("WSO2", "wso2")
This returns a boolean value as the output. In this scenario, it returns "true".
hex (Function)
Returns a hexadecimal string representation of str,
where each byte of each character in str is converted to two hexadecimal digits
Syntax
<STRING> str:hex(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to derive the hexadecimal value. | STRING | No | No |
Examples EXAMPLE 1
hex("MySQL")
This returns the hexadecimal value of the input.string. In this scenario, the output is "4d7953514c".
length (Function)
Returns the length of this string.
Syntax
<INT> str:length(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to derive the length. | STRING | No | No |
Examples EXAMPLE 1
length("Hello World")
This outputs the length of the provided string. In this scenario, the, output is 11
.
lower (Function)
Converts the capital letters in the input string to the equivalent simple letters.
Syntax
<STRING> str:lower(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to convert to the lower case (i.e., equivalent simple letters). | STRING | No | No |
Examples EXAMPLE 1
lower("WSO2 cep ")
This converts the capital letters in the input.string to the equivalent simple letters. In this scenario, the output is "wso2 cep ".
regexp (Function)
Returns whether this 'string' matches the given regular expression 'regex' or not.
Syntax
<BOOL> str:regexp(<STRING> input.string, <STRING> regex)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to match with the given regular expression. | STRING | No | No | |
regex | The regular expression to be matched with the input string. | STRING | No | No |
Examples EXAMPLE 1
regexp("WSO2 abcdh", "WSO(.*h)")
This returns a boolean value after matching regular expression with the given string. In this scenario, it returns "true" as the output.
repeat (Function)
Repeats a string for a specified number of times.
Syntax
<STRING> str:repeat(<STRING> input.string, <INT> times)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string that is repeated the number of times as defined by the user. | STRING | No | No | |
times | The number of times the input.string needs to be repeated . | INT | No | No |
Examples EXAMPLE 1
repeat("StRing 1", 3)
This returns a string value by repeating the string for a specified number of times. In this scenario, the output is "StRing 1StRing 1StRing 1".
replaceAll (Function)
Replaces each substring of this string that matches the given expression with the given replacement.
Syntax
<STRING> str:replaceAll(<STRING> input.string, <STRING> regex, <STRING> replacement.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to be replaced. | STRING | No | No | |
regex | The regular expression to be matched with the input string. | STRING | No | No | |
replacement.string | The striing with which each substring that matches the given expression should be replaced. | STRING | No | No |
Examples EXAMPLE 1
replaceAll("hello hi hello", 'hello', 'test')
This returns a string after replacing the substrings of the input string with the replacement string. In this scenario, the output is "test hi test" .
replaceFirst (Function)
Replaces the first substring of this string that matches the given expression, with the given replacement.
Syntax
<STRING> str:replaceFirst(<STRING> input.string, <STRING> regex, <STRING> replacement.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string that should be replaced. | STRING | No | No | |
regex | The regular expression with which the input string should be matched. | STRING | No | No | |
replacement.string | The string with which the first substring of input string that matches the regular expression should be replaced. | STRING | No | No |
Examples EXAMPLE 1
replaceFirst("hello WSO2 A hello", 'WSO2(.*)A', 'XXXX')
This returns a string after replacing the first substring with the given replacement string. In this scenario, the output is "hello XXXX hello".
reverse (Function)
Returns the reverse ordered string of the input.
Syntax
<STRING> str:reverse(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to be reversed. | STRING | No | No |
Examples EXAMPLE 1
reverse("Hello World")
This outputs a string value by reversing the incoming input.string
. In this scenario, the output is "dlroW olleH".
split (Function)
Splits the source string by split.string
and returns the substring specified via the group.number
.
Syntax
<STRING> str:split(<STRING> input.string, <STRING> split.string, <INT> group.number)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to be replaced. | STRING | No | No | |
split.string | The string value to be used to split the input.string . |
STRING | No | No | |
group.number | The index of the split group | INT | No | No |
Examples EXAMPLE 1
split("WSO2,ABM,NSFT", ",", 0)
This splits the given input.string
by given split.string
and returns the string in the index given by group.number. In this scenario, the output will is "WSO2".
strcmp (Function)
Compares two strings lexicographically.
Syntax
<INT> str:strcmp(<STRING> arg1, <STRING> arg2)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
arg1 | The first input string argument. | STRING | No | No | |
arg2 | The second input string argument that should be compared with the first argument lexicographically. | STRING | No | No |
Examples EXAMPLE 1
strcmp("AbCDefghiJ KLMN", 'Hello')
This compares two strings lexicographically and outputs an integer value
substr (Function)
This returns a new string that is a substring of this string
Syntax
<STRING> str:substr(<STRING> input.string, <INT> begin.index, <INT> length, <STRING> regex, <INT> group.number)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string to be processed. | STRING | No | No | |
begin.index | Starting index to consider for the substring. | INT | No | No | |
length | The length of the substring. | INT | No | No | |
regex | The regular expression that should be matched with the input string.. | STRING | No | No | |
group.number | The regex group number | INT | No | No |
Examples EXAMPLE 1
substr("AbCDefghiJ KLMN", 4)
This outputs the substring based on the given begin.index
. In this scenario, the output is "efghiJ KLMN".
EXAMPLE 2
substr("AbCDefghiJ KLMN", 2, 4)
This outputs the substring based on the given begin.index
and length. In this scenario, the output is "CDef".
EXAMPLE 3
substr("WSO2D efghiJ KLMN", '^WSO2(.*)')
This outputs the substring by applying the regex. In this scenario, the output is "WSO2D efghiJ KLMN".
EXAMPLE 4
substr("WSO2 cep WSO2 XX E hi hA WSO2 heAllo", 'WSO2(.*)A(.*)', 2)
This outputs the substring by applying the regex and considering the group.number
. In this scenario, the output is " ello".
trim (Function)
Returns a copy of the string with leading and trailing whitespace omitted
Syntax
<STRING> str:trim(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string that needs to be trimmed. | STRING | No | No |
Examples EXAMPLE 1
trim(" AbCDefghiJ KLMN ")
This returns a copy of the input.string
with the leading and/or trailing white-spaces omitted. In this scenario, the output is "AbCDefghiJ KLMN".
unhex (Function)
unhex(str)
interprets each pair of characters in the argument as a hexadecimal number
and converts it to the byte represented by the number
Syntax
<STRING> str:unhex(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The hexadecimal input string that needs to be converted to string. | STRING | No | No |
Examples EXAMPLE 1
unhex("4d7953514c")
This converts the hexadecimal value to string
upper (Function)
Converts the simple letters in the input string to the equivalent capital/block letters.
Syntax
<STRING> str:upper(<STRING> input.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
input.string | The input string that should be converted to the upper case (equivalent capital/block letters). | STRING | No | No |
Examples EXAMPLE 1
upper("Hello World")
This converts the simple letters in the input.string
to theequivalent capital letters. In this scenario, the output is "HELLO WORLD".