Here are all the functions usable on the mappings section to transform expressions
Split
split a string into a list of items
split(string, separator)
examples
split("This is a sentence", " ") => ["This", "is", "a" "sentence"]
split("This is a sentence", " ")[1] => "is"
Replace
replace all occurrences of a text by another
replace(string, old, new)
example
replace("This is a sentence", "sentence", "paragraph") => "This is a paragraph"
Substring
extract a substring from a string
substring(string, start, length)
example
substring("This is a sentence", 2, 10) => "is is a "
Concat
concatenate multiple string
concat(strings ...string)
example
concat("This", " ", "is", " ", "a", " ", "sentence") => "This is a sentence"
concatenate multiple string arrays
concat(slices ...[]string)
example
concat(["This", " ", "is", " ", "a", " ", "sentence"]) => "This is a sentence"
Join
merge strings arrays into a single string
join(slice []string, sep string)
example
join(["This is", "a sentence"], " ") => "This is a sentence"
Feed
retrieve data from a source feed
feed(feedId, fieldName)
example
feed(12345678, "targetCountry")
Feed percentile
returns the value of a percentile for a field
feed_percentile(feedId, fieldName, percentile)
example
feed(12345678, "price.value", 95.0) => 101.31
Regexp replace
replace all regexp matches by another value. use $1, $2 in replacement to get capture groups
regexp_replace(value, regexp, replacement)
example
regexp_replace("Smith, John David", "^(\w+),(\s\w+)(\s\w+)?(\s\w+)?","$2$3$4 $1") => "John David Smith"
Regexp extract
returns the first substring that matches the expression
regexp_extract(value, regexp)
example
regexp_extract("https://www.test.com/?utm_campaign=christmas", "^[^?#]+\?utm_campaign=(.*)") => "christmas"
Upper
convert a string to uppercase
upper(string)
example
upper("This is a sentence") => "THIS IS A SENTENCE"
Lower
convert a string to lowercase
lower(string)
example
lower("This is a sentence") => "this is a sentence"
Trim
remove leading and trailing whitespace
trim(string)
example
trim(" This is a sentence ") => "This is a sentence"
Mapping
returns the value of a another mapping
mapping(string)
example
mapping("targetCountry") => "EN"
If
if expression is not empty returns true_result, else returns else_result
if(expression, true result, false result)
example
if("expression", "this result exists", "this result is empty") => "this result exists"
Contains
check if a string contains a substring
contains(string, substring)
example
contains("This is a sentence", "sentence") => true
Length
returns the length of a string
len(string)
example
len("sentence") => "8"
returns the length of an array
len(array)
example
len(["431", "649", "233", "865", "903", "129", "451"]) => "7"
String
convert an integer to string
str(integer)
example
str(56) => "56"
convert a decimal to string
str(decimal)
example
str(34.74) => "34.74"
convert a boolean to string
str(boolean)
example
str(3 > 4) => "false"
Int
convert a string to an integer
int(string)
example
int("56") => 56
convert a decimal to an integer
int(decimal)
example
int(34.74) => 34
convert a boolean to an integer
int(boolean)
example
int(3 > 4) => 0
Float
convert an integer to a decimal
float(integer)
example
float(56) => 56.0
convert a string to a decimal
float(string)
example
float("34.74") => 34.74
convert a boolean to decimal
float(boolean)
example
float(3 > 4) => 0.0
Query params
extract a parameter from a URL
query_param(url, param)
example
query_param("https://www.test.com/?utm_campaign=christmas", "utm_campaign") => "christmas"
The next functions will be Math functions. All results using them will be fixed at 2 decimals
Round
round a decimal to a given precision
round(decimal, precision)
example
round("10.67") => "11.00"
round("8.23") => "8.00"
round a decimal with zero precision
round(decimal)
example
round("10.67") => "11.00"
round("8.23") => "8.00"
Ceil
returns the least integer value greater than or equal to the given number
ceil(float(string))
example
ceil("10.67") => "11.00"
Floor
returns the least integer value less than or equal to the given number
floor(float(string))
example
floor("10.67") => "10.00"
Min
returns the smaller of two given numbers
min(float(string), float(string))
example
min("24.48", "98.11") => "24.48"
Max
returns the larger of two given numbers
max(float(string), float(string))
example
max("24.48", "98.11") => "98.11"