You are viewing the documentation for Blueriq 15. Documentation for other versions is available in our documentation directory.
Learn more about text functions CONCATENATE, JOIN, MATCH, FIND, FIRST, LAST, LENGTH, UPPERCASE, LOWERCASE, CAPITALIZE, TRIM, INDEXOF, LASTINDEXOF, SUBSTRING, SUBSTRING BEFORE, SUBSTRING AFTER, SPLIT, REPLACE, EQUALS.
Overview
Function | Description |
---|---|
CONCATENATE | Use the '+ ' (plus) operator to concatenate strings or a combination of strings and other type values to produce a single string value. |
Joins a series of values into one string, separated with a character of your choice. | |
MATCH | Compares a string pattern to another string and returns TRUE if the string exactly matches the pattern, and otherwise FALSE. The MATCH function is case-sensitive. |
FIND | Looks for a string pattern within another string and returns the first matching characters. The function is case-sensitive. |
FIRST | Returns the first character(s) of a string, based on the number of characters you specify. |
LAST | Returns the last character(s) of a string, based on the number of characters you specify. |
LENGTH | Returns the length of a string. |
UPPERCASE | Returns a string with all characters in uppercase. |
LOWERCASE | Returns a string with all characters in lowercase. |
CAPITALIZE | Returns a string with the first character uppercased. |
TRIM | Strips the leading and trailing spaces from a string. |
INDEXOF | Returns the index of the first occurrence of a specified substring in a string. |
LASTINDEXOF | Returns the index of the last occurrence of a specified substring in a string. |
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. |
SUBSTRING BEFORE | Returns the start of a given string before the first occurrence of substring, or an empty string if substring is not found. |
SUBSTRING AFTER | Returns the end of a given string after the first occurrence of substring, or an empty string if substring is not found. |
SPLIT | Returns a multivalued string attribute containing every substring that is delimited by the given pattern. |
REPLACE | Replaces every occurrence of a string pattern within another string with a provided replacement string. The function is case-sensitive. |
EQUALS | Compares two strings and returns TRUE if and only if they are equal. This function is case sensitive. |
Go here for more info on the Text Substitution Language (TSL) documentation.
Functions
CONCATENATE
Use the '+
' (plus) operator to concatenate strings or a combination of strings and other type values to produce a single string value.
Syntax
string1 + string2 + ... + value1 + ...
- string1 - The first string that you want to concatenate.
- string2 - The second string that you want to concatenate.
- value1 - A value of some type of number, date or boolean that you want to add to the new string value.
Return type
- string
Examples
Expression | Result | Type |
---|---|---|
12 + " kilometers" | "12 kilometers" | String |
"This statement is " + TRUE + "." | "This statement is true." | String |
"I was born on " + Me.birthDateAndTime + "." | "I was born on Tue Dec 01 23:00:45 CET 1970." | String |
( UPPERCASE "hello" ) + ( LOWERCASE " WORLD" ) | "HELLO world" | String |
UPPERCASE( "hello" ) + LOWERCASE( " WORLD" ) | "HELLO WORLD" | String |
Suppose Person.FirstName = "Carl" Person.LastName = then Person.FirstName + Person.LastName | ? (UNKNOWN) | String |
Note the correct use of parenthesis in combination with concatenation, see UPPERCASE and LOWERCASE syntax.
There exists a STR_CONCAT ( string , string )
function in the expression language. As it can only concatenate two strings, and is much longer in typing, we advise to use above way for concatenating strings.
JOIN
Joins a series of values into one string, separated with a character of your choice.
Syntax
JOIN ( argument1 , argument2 , ... , separator )
- argument1, argument2 - Attributes or expressions that contain the values that will be joint to a single string. JOIN works for all base types, even multivalued.
- separator - A string value that will be used as separator symbol.
Return type
- string
The CONCAT
function is identical to the JOIN
function, except for handling of UNKNOWN.
Examples
Suppose you have a model containing the following attributes.
Attribute | Basetype | Value |
---|---|---|
Person.name | string | "John" |
Person.date_of_birth | date | 01-01-1995 |
Person.family_name | string |
Expression | Result | Type |
---|---|---|
JOIN ( Person.name , Person.date_of_birth , ";" ) | "John;Sun Jan 01 00:00:00 CET 1995" | String |
JOIN ( Person.name , Person.name , "@" ) | "John@John" | String |
JOIN ( Person.name , Person.family_name , YEARS BETWEEN Person.date_of_birth AND DATE ( 2015 , 01 , 01 ) , ";" ) | "John;;20" | String |
MATCH
Compares a string pattern to another string and returns TRUE if the string exactly matches the pattern, and otherwise FALSE. The MATCH function is case-sensitive.
Syntax
MATCH ( pattern , string )
Inputs
- pattern - 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 1.4 expressions. For a complete documentation we refer to the online java documentation.
- string - String value, attribute of base type string or an expression that results in a string value.
Return type
- boolean
Examples
Entity.attribute | Value | Type |
---|---|---|
File.name | "Thisfile_1.doc" | String |
Expression | Result | Type |
---|---|---|
MATCH ( "Thisfile_1.doc" , File.name ) | TRUE | boolean |
MATCH ( File.name , "Thisfile_1.doc" ) | TRUE | boolean |
MATCH ( " Thisfile_1.doc" , File.name ) | FALSE | boolean |
MATCH ( "thisfile_1.doc" , File.name ) | FALSE | boolean |
MATCH ( "[A-Z]hisfile_1.doc" , File.name ) | TRUE | boolean |
MATCH ( "[a-z]hisfile_1.doc" , File.name ) | FALSE | boolean |
MATCH ( "Thisfile_[0-9].doc" , File.name ) | TRUE | boolean |
MATCH ( ".............." , File.name ) | TRUE | boolean |
MATCH ( ".*" , File.name ) | TRUE | boolean |
MATCH ( "**" , "**" ) | Error | "**" is not a valid regular expression |
FIND
Looks for a string pattern within another string and returns the first matching characters. The function is case-sensitive.
Syntax
FIND ( pattern , string ) FIND ( pattern , string , startIndex )
- pattern - 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 1.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.
- startIndex - A positive integer value indicating at which character of the string the search should start (inclusive). This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value. The first character starts at index 0.
Return type
- string
Examples
Entity.attribute | Value | Type |
---|---|---|
File.name | "Thisfile_1.doc" | String |
Expression | Result | Type |
---|---|---|
FIND ( "_[1-5]" , File.name ) | "_1" | String |
FIND ( "File" , File.name ) | UNKNOWN | String |
FIND ( "el" , "Hello" ) | "el" | String |
FIND ( "el" , "Hello" , 2 ) | UNKNOWN | String |
FIND ( "eo" , "Hello" ) | UNKNOWN | String |
FIND ( "\s[a-zA-Z]+" , "Hello world example" ) | "world" | String |
FIND ( "\s[a-zA-Z]+" , "Hello world example" , 6 ) | "example" | String |
FIRST
Returns the first character(s) of a string, based on the number of characters you specify.
Syntax
FIRST integer CHARACTERS OF string FIRST CHARACTER OF string
- integer - A positive integer value. This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value. FIRST CHARACTER OF can be used to retrieve only the first character of the string.
- string - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- string
If you prefer a functional syntax, you can use the STR_FRONT( string, integer ) function. Example: STR_FRONT("Blueriq", 3) = "Blu"
Examples
Entity.attribute | Value | Type |
---|---|---|
File.name | "Thisfile_1.doc" | String |
File.prefix | 8 | Integer |
Expression | Alternative syntax | Result | Type |
---|---|---|---|
FIRST File.prefix CHARACTERS OF File.name | STR_FRONT( File.name , File.prefix ) | Thisfile | String |
FIRST CHARACTER OF File.name | STR_FRONT( File.name , 1 ) | T | String |
FIRST 5 CHARACTERS OF "pieceofcake" | STR_FRONT( "pieceofcake" , 5 ) | piece | String |
LAST
Returns the last character(s) of a string, based on the number of characters you specify.
Syntax
LAST integer CHARACTERS OF string LAST CHARACTER OF string
Inputs
- integer - A positive integer value. This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value. LAST CHARACTER OF can be used to retrieve only the last character of the string.
- string - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- string
If you prefer a functional syntax, you can use the STR_BACK ( string, integer ) function. Example: STR_BACK("Blueriq", 3) = "riq"
Examples
Entity.attribute | Value | Type |
---|---|---|
File.name | "Thisfile_1.doc" | String |
File.extension | 3 | Integer |
Expression | Alternative syntax | Result | Type |
---|---|---|---|
LAST File.extension CHARACTERS OF File.name | STR_BACK( File.name , File.extension ) | "doc" | String |
LAST CHARACTER OF File.name | STR_BACK( File.name , 1 ) | "c" | String |
LAST 4 CHARACTERS OF "pieceofcake" | STR_BACK( "pieceofcake" , 4 ) | "cake" | String |
LENGTH
Returns the length of a string.
Syntax
LENGTH ( string )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- integer
Spaces at the start of the end of the string are counted as well, the string is not trimmed.
Example
Expression | Result | Type |
---|---|---|
LENGTH ( "Blueriq" ) | 7 | Integer |
LENGTH ( " Blueriq " ) | 9 | Integer |
LENGTH ( ? ) | ? | Integer |
UPPERCASE
Returns a string with all characters in uppercase.
Syntax
UPPERCASE string
- string - An attribute of base type string, an expression that results in a string or a constant string value.
UPPERCASE does not have a functional syntax. This can have unexpected effects on concatenation. UPPERCASE ( "hello" ) + LOWERCASE ( " WORLD" ) is equivalent to UPPERCASE ( ( "hello" ) + LOWERCASE ( " WORLD" ) ). Use ( UPPERCASE string ) syntax to avoid this behaviour.
Return type
- string
Example
Expression | Result | Type |
---|---|---|
UPPERCASE ( "hello" ) | "HELLO" | String |
UPPERCASE "WORLD" | "WORLD" | String |
UPPERCASE ( "hello world " ) | "HELLO WORLD " | String |
UPPERCASE " hELLo " | " HELLO " | String |
UPPERCASE ( ? ) | ? | String |
( UPPERCASE "hello" ) + ( LOWERCASE " WORLD" ) | "HELLO world" | String |
UPPERCASE ( "hello" ) + LOWERCASE ( " WORLD" ) | "HELLO WORLD" | String |
LOWERCASE
Returns a string with all characters in lowercase.
Syntax
LOWERCASE string
- string - An attribute of base type string, an expression that results in a string or a constant string value.
LOWERCASE does not have a functional syntax. This can have unexpected effects on concatenation. LOWERCASE ( "HELLO" ) + UPPERCASE ( " world" ) is equivalent to LOWERCASE ( ( "HELLO" ) + UPPERCASE ( " world" ) ). Use ( LOWERCASE string ) syntax to avoid this behaviour.
Return type
- string
Example
Expression | Result | Type |
---|---|---|
LOWERCASE ( "hello" ) | "hello" | String |
LOWERCASE "WORLD" | "world" | String |
LOWERCASE ( "hello world " ) | "hello world " | String |
LOWERCASE " hELLo " | " hello " | String |
LOWERCASE ( ? ) | ? | String |
( LOWERCASE "HELLO" ) + ( UPPERCASE " world" ) | "hello WORLD" | String |
LOWERCASE ( "HELLO" ) + UPPERCASE ( " world" ) | "hello world" | String |
CAPITALIZE
Returns a string with the first character uppercased.
Syntax
CAPITALIZE string CAPITALIZE ( string, lowerTheRest )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- lowerTheRest - An attribute of base type boolean, an expression that results in a boolean or a constant boolean value, indicating that the other characters need to be lowercased. This parameter is optional and if it is not supplied, the other characters are left untouched.
Return type
- string
Example
Expression | Result | Type |
---|---|---|
CAPITALIZE "hello" | "Hello" | String |
CAPITALIZE ( "WORLD" ) | "WORLD" | String |
CAPITALIZE ( "hello world " ) | "Hello world " | String |
CAPITALIZE " hELLo " | " hELLo " | String |
CAPITALIZE TRIM " hELLo " | "HELLo" | String |
CAPITALIZE TRIM LOWERCASE " hELLo " | "Hello" | String |
CAPITALIZE ( "hello" , TRUE ) | "Hello" | String |
CAPITALIZE ( "WORLD" , TRUE ) | "World" | String |
CAPITALIZE ( "hello world " , TRUE ) | "Hello world " | String |
CAPITALIZE ( " hELLo " , TRUE ) | " hello " | String |
CAPITALIZE ( TRIM " hELLo " , TRUE ) | "Hello" | String |
CAPITALIZE( ? ) | ? | String |
TRIM
Strips the leading and trailing spaces from a string.
Syntax
TRIM string
Input
- string - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- string
Example
Expression | Result | Type |
---|---|---|
TRIM "Hello" | "Hello" | String |
TRIM ( "Hello World" ) | "Hello World" | String |
TRIM " Hello World " | "Hello World" | String |
TRIM ( ? ) | ? | String |
INDEXOF
Returns the index of the first occurrence of a specified substring in a string.
Syntax
INDEXOF ( string , substring ) INDEXOF ( string , substring , startIndex )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- substring - An attribute of base type string, an expression that results in a string or a constant string value.
- startIndex - A (positive) integer value indicating at which character the search for the substring should start (inclusive). This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value.
The first character starts at index 0.
Return type
- integer - the index of the first occurrence of the specified substring or -1 if it is not found
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 |
LASTINDEXOF
Returns the index of the last occurrence of a specified substring in a string.
Syntax
LASTINDEXOF ( string , substring ) LASTINDEXOF ( string , substring , startIndex )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- substring - An attribute of base type string, an expression that results in a string or a constant string value.
- startIndex - A (positive) integer value indicating at which character the search for the substring should start (inclusive), searching backwards. This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value.
Return type
- integer - the index of the last occurrence of the specified substring or -1 if it is not found
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 |
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
SUBSTRING ( string , startIndex ) SUBSTRING ( string , startIndex , endIndex )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- startIndex - A positive integer value indicating at which character the substring should start (inclusive). This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value. The first character starts at index 0.
- endIndex - A positive integer value indicating at which character the substring should end (exclusive). This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value. The
endIndex
cannot exceed the length of the string and should be larger than the startIndex.
Return type
- string
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 |
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
SUBSTRING BEFORE substring IN string SUBSTRING_BEFORE ( string , substring )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- substring - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- string
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 |
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
SUBSTRING AFTER substring IN string SUBSTRING_AFTER ( string , substring )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- substring - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- string
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 |
SPLIT
Returns a multivalued string attribute containing every substring that is delimited by the given pattern.
Syntax
SPLIT string ON pattern SPLIT ( string , pattern )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- pattern - 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 1.4 expressions. For a complete documentation we refer to the online java documentation.
Return type
- string (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 function: | ||
JOIN ( SPLIT ( "H.E.L.L.O" , "\.") , "" ) | "HELLO" | String |
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.
REPLACE
Replaces every occurrence of a string pattern within another string with a provided replacement string. The function is case-sensitive.
Syntax
REPLACE pattern IN string WITH replacement REPLACE ( pattern , string , replacement )
- pattern - 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 1.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 is returned.
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 |
EQUALS
Compares two strings and returns TRUE if and only if they are equal. This function is case sensitive.
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
string1 EQUALS string2 EQUALS ( string1 , string2 )
Inputs
- string1 - An attribute of base type string, an expression that results in a string or a constant string value.
- string2 - An attribute of base type string, an expression that results in a string or a constant string value.
Return type
- boolean
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 |