INDEXOF
returns
Returns the index of the first occurrence of a specified substring in a string.
Syntax Code Block |
---|
INDEXOF ( string , substring )
INDEXOF ( string , substring , startIndex ) |
Inputs
Return type
Example Expression | Result | Type |
---|
INDEXOF ( "Hello world" , "o" ) | 4 | Integer | INDEXOF ( "Hello world" , "o" , 5 ) | 7 | Integer | INDEXOF ( "Hello world" , "a" ) | -1 | Integer | INDEXOF ( "Hello world" , "o" , 8 ) | -1 | Integer | INDEXOF ( "Hello world" , "o" , -12 ) | 4 | Integer | INDEXOF ( "Hello world" , "o" , 50 ) | -1 | Integer |
|
UI Text Box |
---|
|
Info |
---|
There is no restriction on the value of startIndex. If it is negative, it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string, it has the same effect as if it were equal to the length of this |
|
string: -1 is returned. Panel |
---|
|
LASTINDEXOF
LASTINDEXOF
returns the index of the last occurrence of a specified substring in a string.
Syntax
Code Block |
---|
LASTINDEXOF ( string , substring )
LASTINDEXOF ( string , substring , startIndex ) |
Inputs
Return type
Example
Expression | Result | Type |
---|
LASTINDEXOF ( "Hello world" , "o" ) | 7 | Integer |
LASTINDEXOF ( "Hello world" , "o" , 6 ) | 4 | Integer |
LASTINDEXOF ( "Hello world" , "a" ) | -1 | Integer |
LASTINDEXOF ( "Hello world" , "o" , 3 ) | -1 | Integer |
LASTINDEXOF ( "Hello world" , "o" , -12 ) | -1 | Integer |
LASTINDEXOF ( "Hello world" , "o" , 50 ) | 7 | Integer |
UI Text Box |
---|
|
There is no restriction on the value of startIndex. If it is negative, it has the same effect as if it were zero: -1 is returned since there are no characters before character 0. If startIndex is greater than the length of this string, it has the same effect as if it were equal to the length of this string, so the whole string is searched. |
Panel |
---|
|
SUBSTRING
SUBSTRING
returns the substring of a given string starting from the index provided and ending at the end index if provided, or the end of the string.
Syntax
Code Block |
---|
SUBSTRING ( string , startIndex )
SUBSTRING ( string , startIndex , endIndex ) |
Inputs
Return type
Example
Expression | Result | Type |
---|
SUBSTRING ( "Hello world" , 1 ) | "ello world" | String |
SUBSTRING ( "Hello world" , 0 , 1 ) | "H" | String |
SUBSTRING ( "Hello world" , 1 , 5 ) | "ello" | String |
SUBSTRING ( "Hello world" , 0 ) | "Hello world" | String |
SUBSTRING ( "Hello world" , 0 , LENGTH( "Hello world" ) ) | "Hello world" | String |
Panel |
---|
|
SUBSTRING BEFORE
SUBSTRING_BEFORE
returns the start of a given string before the first occurrence of substring, or an empty string if substring is not found
Syntax
Code Block |
---|
SUBSTRING BEFORE substring IN string
SUBSTRING_BEFORE ( string , substring ) |
Inputs
Return type
Example
Expression | Result | Type |
---|
SUBSTRING BEFORE ":" IN "hello:world" | "hello" | String |
SUBSTRING_BEFORE ( "hello:world" , ":" ) | "hello" | String |
SUBSTRING_BEFORE ( "hello:world:all" , ":" ) | "hello" | String |
SUBSTRING_BEFORE ( "hello:world" , "h" ) | "" | String |
SUBSTRING BEFORE "a" IN "hello:world" | "" | String |
SUBSTRING_BEFORE ( "" , "hello" ) | "" | String |
SUBSTRING_BEFORE ( "hello" , "" ) | "" | String |
Panel |
---|
|
SUBSTRING AFTER
SUBSTRING_AFTER
returns the end of a given string after the first occurrence of substring, or an empty string if substring is not found.
Syntax
Code Block |
---|
SUBSTRING AFTER substring IN string
SUBSTRING_AFTER ( string , substring ) |
Inputs
Return type
Example
Expression | Result | Type |
---|
SUBSTRING AFTER ":" IN "hello:world" | "world" | String |
SUBSTRING_AFTER ( "hello:world:all" , ":" ) | "world:all" | String |
SUBSTRING AFTER "a" IN "hello:world" | "" | String |
SUBSTRING_AFTER ( "" , "hello" ) | "" | String |
SUBSTRING_AFTER ( "hello" , "" ) | "hello" | String |
Panel |
---|
|
SPLIT
SPLIT
returns a multivalued attribute containing every substring that is delimited by the given pattern.
Syntax
Code Block |
---|
SPLIT string ON pattern
SPLIT ( string , pattern ) |
Inputs
Return type
(multivalued)Example
Expression | Result | Type |
---|
SPLIT "Hello world" ON "o" | [ "Hell" , " w" , "rld" ] | String (multivalued) |
SPLIT ( "Hello world" , "a" ) | [ "Hello world" ] | String (multivalued) |
SPLIT "Hello" ON "o" | [ "Hell" ] | String (multivalued) |
SPLIT ( "ooo" , "o" ) | [ ] | String (multivalued) |
SPLIT ( "bot" , "o" ) | [ "b" , "t" ] | String (multivalued) |
SPLIT ( "boot" , "o" ) | [ "b" , "", "t" ] | String (multivalued) |
SPLIT ( "booot" , "o" ) | [ "b" , "", "t" ] | String (multivalued) |
To remove dots from a string in combination with the JOIN functionJOIN ( SPLIT ( "H.E.L.L.O" , "\.") , "" ) | "HELLO" | String |
UI Text Box |
---|
|
If you use the SPLIT in a default expression on an multivalued attribute, please note that the result will be stored as collection, meaning that all duplicates will be removed. To illustrate this: suppose we have an attribute Test.Splitted (multivalued), which has the default expression SPLIT ( "H.E.L.L.O" , "\.") . The result of the expression JOIN ( Test.Splitted , "" ) = "HELO" instead of "HELLO" as in the last example. |
Panel |
---|
|
REPLACE
The REPLACE
function replaces every occurrence of a string pattern within another string with a provided replacement string. The function is case-sensitive.
Syntax
Code Block |
---|
REPLACE pattern IN string WITH replacement
REPLACE ( pattern , string , replacement ) |
Inputspattern An attribute of base type string or a string value. String must be a valid regular expression. The regular expressions used in several Blueriq Studio functions are common Java .4 expressions. For a complete documentation we refer to the online java documentation.string - An attribute of base type string or an expression that results in a string.
replacement - An attribute of base type string or an expression that results in a string.Return type
string. If the pattern is not found, the original string Examples
Expression | Result | Type |
---|
REPLACE ":" IN "hello:world:example" WITH " " | "hello world example" | String |
REPLACE ( "o" , "hello world" , "a" ) | "hella warld" | String |
REPLACE ( "O" , "hello world" , "a" ) | "hello world" | String |
REPLACE "\s" IN "hello world example" WITH "" | "helloworldexample" | String |
REPLACE ( "\d{2}" , "hello1 world22 example333" , "@" ) | "hello1 world@ example@3" | String |
REPLACE ( "" , "hello world" , " " )" h e l l o w o r l d " | String | REPLACE "\s" IN "hello world example" WITH "\s" | "hello\sworld\sexample" | String |
UI Text Box |
---|
|
The first argument is a pattern (regular expression) and can therefore contain specials like \s for a space. The second and third arguments are strings or expressions, so \s will result in \s. |
Panel |
---|
|
EQUALS
EQUALS
compares two strings and returns TRUE if and only if they are equal. This function is case sensitive.
UI Text Box |
---|
|
Only use this function if you need a case sensitive comparison of two strings. If you want to compare strings case insensitive, use the '=' operator instead. |
Syntax
Code Block |
---|
string1 EQUALS string2
EQUALS ( string1 , string2 ) |
Inputs
Return type
Example
Expression | Result | Type | Note |
---|
"hello" EQUALS "hello" | TRUE | Boolean | EQUALS ( "hello" , "Hello" ) | FALSE | Boolean | FALSE because EQUALS is case sensitive |
"hello" EQUALS "hello " | FALSE | Boolean | FALSE because of trailing space |
EQUALS ( "" , "" ) | TRUE | Boolean |