Truncate a string at a word boundary close to the given position.

Syntax

Smartsite SXML CopyCode image Copy Code
string string.truncate(string data, integer targetLength)
string string.truncate(string data, integer targetLength, integer maxDeviation)
string string.truncate(string data, integer targetLength, integer maxDeviation, string suffix)
string string.truncate(string data, integer targetLength, string suffix)

Parameters

Name Data Type Description
data String The input string.
targetLength Integer The optimal length for the truncated string.
maxDeviation Integer The allowed difference in length between the optimal length and the actual length. Default is 20% of targetLength.
suffix String String to append to output if the input is actually truncated.

Return Value

Data Type Description
String The truncated string.

Expand image Example

SXML