Text Examples
In the sections below, the calculated attribute text functions are grouped by purpose and are demonstrated in simple terms using a variety of value templates:
- Escape Functions can be used to allow for special characters during text manipulation.
- Identify Functions can be used to display the defined data.
- Modify Functions can be used to modify defined data.
- Regular Expression Functions can be used to search and modify text based on a defined template.
- Representative Text Functions can be used to produce an alternative value for the defined text.
- Test Functions can be used to perform a test and return a result.
For function syntax information and more detailed use cases, refer to the Text Functions documentation here.
Escape Functions
These functions can be used to allow for special characters during text manipulation.
The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
Notes |
---|---|---|
escapemerge(';', '/', "Red", "Orange; Blue", "Violet") |
Red;Orange/; Blue;Violet |
Write semicolon (;) (split character) after each element and include slash (/) (escape character) when split character is found in text. |
escapesplit(';', '/', 'Red;Orange/; Blue;Violet') |
RedOrange; BlueViolet |
Write elements without semicolon (;) (split character) unless it is escaped with a slash (/) (escape character). |
Identify Functions
These functions can be used to display the defined data.
The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
Notes |
---|---|---|
left('hello') |
h |
1 character from left |
left('hello',3) |
hel |
3 characters from left |
right('hello') |
o |
1 character from right |
right('hello', 3) |
llo |
3 characters from right |
mid('hello',2,3) |
ell |
3 characters starting at character 2 |
len('hello') |
5 |
number of characters in string |
Modify Functions
These functions can be used to modify defined data.
The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
Notes |
---|---|---|
concatenate("hello", "hallo") |
hellohallo |
join multiple text strings into a single text string |
trim(' hello ') |
hello |
remove spaces before and after text |
upper('hello') |
HELLO |
convert to uppercase letters |
lower('HELLO') |
hello |
convert to lowercase letters |
proper("hello, are you john's son?") |
Hello, Are You John'S Son? |
capitalize the first letter of each word, including capitalization after punctuation |
firstnamefirst("Johnson, John S.") |
John S. Johnson |
transpose words using comma as separator |
firstnamefirst("Joe Dalton") |
Joe Dalton |
transpose words using comma as separator |
replace('hello',2,3,'el') |
helo |
insert 'el' in place of 3 characters, starting at character 2 |
substitute('hellohellohello', 'ell', 'al') |
halohalohalo |
update all instances of 'ell' with 'al' |
substitute('hellohellohello', 'ell', 'al', 2) |
hellohalohello |
update only instance 2 of 'ell' with 'al' |
Formatting Text
The example calculated attributes below use an object with the attribute values defined in the following table.
Attribute> |
height |
width |
length |
Product1 |
50 cm |
135 cm |
75 cm |
Product2 |
50 cm |
|
75 cm |
Note: Text used for 'attribute-id' and 'unit-id' is case-sensitive.
After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.
Value Template |
Object |
Result |
Notes |
---|---|---|---|
concatenate( prodval('height'), prodval('width'), prodval('length')) |
Product1 |
5013575
|
Concatenating only the values excludes the unit information and results in an unformatted number.
|
concatenate( prodvalsimple('height','unece.unit.CMT'),' H x ', prodvalsimple('width','unece.unit.CMT'),' W x ', prodvalsimple('length','unece.unit.CMT'),' L') |
Product1 |
50 cm H x 135 cm W x 75 cm L |
Static text strings provide a typical display for dimension information.
|
list(listconcatenate( prodval("height"), prodval("width"), prodval("length")),'*') |
Product2 |
50*75 |
Since the width value is empty, this needs to be concatenated without an extra separator '*' so the LISTCONCATENATE and LIST functions are used. Alternatively, the IF function can be used to check whether a value is empty or not before concatenating, but would require additional code to check for each concatenating value. |
The example calculated attributes below use an object with the attribute values defined in the following table.
Attribute> |
prodname |
Product3 |
ACME-BP-1001 Super XBP |
Note: Text used for 'attribute-id' is case-sensitive.
After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.
Value Template |
Object |
Result |
Notes |
---|---|---|---|
replace(prodval('prodname'), 6,2,'Boardroom Projector Series') |
Product3 |
ACME-Boardroom Projector Series-1001 Super XBP
|
Update the first occurrence of BP while leaving the second instance untouched. Note: If the position (6) or length (2) to be replaced was miscounted, whatever text is found at the location will be replaced. |
substitute(prodval('prodname'), '-BP-',' Boardroom Projector Series ') |
Product3 |
ACME Boardroom Projector Series 1001 Super XBP |
Update all occurrences of -BP-, so that the second instance of BP is not changed.
|
substitute(prodval('prodname'), 'BP','Boardroom Projector Series') |
Product3 |
ACME-Boardroom Projector Series-1001 Super XBoardroom Projector Series |
Update all occurrences of BP. |
substitute(prodval('prodname'), 'BP','Boardroom Projector Series',1) |
Product3 |
ACME-Boardroom Projector Series-1001 Super XBP |
Update only the first occurrence of BP. |
Regular Expression Functions
These functions can be used to search and modify text based on a defined template.
For more information on creating regular expressions, refer to the Regular Expression documentation here.
The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
Notes |
---|---|---|
regexpsearch('e.*he', 'hellohello') |
2 |
2 is the start point for 'ellohe' as a case sensitive match for the regexp |
regexpsearch('[ABC]\\d', 'HELLOHA2MSTER') |
7 |
7 is the start point for 'A' + any digit as a case sensitive match for the regexp. [ ] indicates only one of the enclosed letters is required. \\d indicates a digit. |
regexpsearchi('[efg]|[ojk]', 'HELLOHELLO')
|
2 |
2 is the start point for 'E' as a case insensitive match for the regexp looking for either 'e, f, g' or 'o, j, k'. [ ] indicates only one of the enclosed letters is required. | indicates 'or.' |
regexpsearchi('[abc]|[ojk]', 'HELLOHELLO', 3) |
5 |
Searching starting at position 3, 5 is the start point for 'O' as a case insensitive match for the regexp looking for either 'a, b, c' or 'o, j, k'. [ ] indicates only one of the enclosed letters is required. | indicates 'or.' |
regexpsubstitute("kat;abe", "(.*);(.*)", "$2$1") |
abekat |
Save all characters before the semicolon in Group 1, save all characters after the semicolon in Group 2; display Group 2 then Group 1, without any space or the semicolon |
regexpsubstitute("kat abe", "(\\w*)\\s*(\\w*)", "$2$1")
|
abekat |
Find first word (and save it in Group 1) followed by a space, then find another word (and save it in Group 2), display Group 2 then Group 1 without the space. \\w indicates a word and \\s indicates a space. |
Representative Text Functions
These functions can be used to produce an alternative value for the defined text.
The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
---|---|
soundex("hello") |
H400 |
metaphone3("Joel Dalton") |
JLTLTN |
metaphone3alternate("Joel Dalton") |
ALTLTN |
Test Functions
The functions can be used to perform a test and return a result.
The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
Notes |
---|---|---|
exact("hello", "hallo") |
0 |
Exact match not found |
exact("hello", "hello") |
1 |
Exact match is found |
if (exact('hello','you'), 'true', 'false') |
false |
Exact match is not found so the second result is returned |
find('llo','hellohello') |
3 |
The position of the first occurrence |
find('llo','hellohello', 4) |
8 |
The position of the first occurrence found after character 4 |
find('lllo','hellohello') |
N/A |
Match is not found |
Testing Text
The example calculated attributes below use an object with the attribute values defined in the following table.
Attribute> |
PowerCordIncluded |
Product4 |
Yes |
Product5 |
yes |
After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.
Value Template |
Object |
Result |
---|---|---|
if(exact(prodval('PowerCordIncluded'),'Yes'), 'A 2 meter power cord is included.', 'Power cord is not included.') |
Product4 Product5 |
A 2 meter power cord is included. Power cord is not included. |