---
schema_version: "1"
id: a08ef5a4b0bca8e256118544ca6eb21cadd20d3d682fd8605fb6bc1f7c4144db
title: substringAfterLast
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-strings-functions-substringafterlast.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-strings-functions-substringafterlast
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7c9b8bd6876cbf8db152f01ec968c3c54d976898ec8b1c8498dd6f5a78d8d124
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# substringAfterLast

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## substringAfterLast(text: String, separator: String): String

Gets the substring after the last occurrence of a separator. The separator is not returned.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr><tr><td><p><code>separator</code></p></td><td><p>String to search for.</p></td></tr></tbody></table>

### Example

This example shows how `substringAfterLast` behaves with different inputs and sizes.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "a": substringAfterLast(null, "'"),
  "b": substringAfterLast("", "-"),
  "c": substringAfterLast("abc", "b"),
  "d": substringAfterLast("abcba", "b"),
  "e": substringAfterLast("abc", "d"),
  "f": substringAfterLast("abc", "")
}
```

#### Output

```JSON
{
 "a": null,
 "b": "",
 "c": "c",
 "d": "a",
 "e": "",
 "f": null
}
```

## substringAfterLast(text: Null, separator: String): Null

Helper function that enables `substringAfterLast` to work with a `null` value.

_Introduced in DataWeave version 2.2.0._
