Contact Us 1-800-596-4880

last

last(text: String, amount: Number): String

Returns characters from the end of string to a specified number of characters, for example, the last two characters of a string.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

text

The string to process.

amount

The number of characters to return. Negative numbers and 0 return an empty string. Decimals are rounded up to the nearest whole number.

Example

This example returns the last six characters from a string.

Source

%dw 2.0
import last from dw::core::Strings
output application/json
---
"hello world!" last 6

Output

"world!"

last(text: Null, amount: Any): Null

Helper function that enables last to work with a null value.

Introduced in DataWeave version 2.4.0.