The function fn:substringBefore extracts the subset of a string before the first occurrence of a specific substring. The value returned is a string data type.

Example

Values stored in a group attribute represent prices for accommodations in various cities. Prices are saved as fractional numbers to two decimal places. When the price of a hotel in London is inserted into a message, the decimal values are replaced with a dash and preceded by the pound sign (i.e. 255.85 is converted to £255.-). The function fn:substringBefore extracts the value before the decimal point from the attribute ​Rate_London​ as follows:

${fn:substringBefore(group.CustomAttribute['Rate_London'], '.')}
CODE

If the current value stored in the custom attribute is 255.85, the string returned by the function is 255. The currency symbol, decimal point and dash (in this example, £255.-) must be added to the result with an additional function, .fn:substringBefore v1.0.

Structure​

fn:substringBefore(string, string)

Parameters​

Parameter

Description

string

Specifies the target string.

string

The value (substring) used to query the target.