---
schema_version: "1"
id: d8a5187abf4598551e2c1e0264cd4093be4f398310cc7847b6196403f998ae70
title: with
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-core-functions-with.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-core-functions-with
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 32d2f208ae4e5f228bea50e6f5380c68ac0d1ffdd49e4b26bea1e9655c92b826
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# with

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

## with<V, U, R, X>(toBeReplaced: ((V, U) -> R) -> X, replacer: (V, U) -> R): X

Helper function that specifies a replacement element. This function is used with `replace`, `update`
or `mask` to perform data substitutions.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>toBeReplaced</code></p></td><td><p>The value to be replaced.</p></td></tr><tr><td><p><code>replacer</code></p></td><td><p>The replacement value for the input value.</p></td></tr></tbody></table>

### Example

This example replaces all numbers in a string with "x" characters. The `replace` function specifies
the base string and a regex to select the characters to replace, and `with` provides the replacement
string to use.

#### Source

```DataWeave
%dw 2.0
output application/json
---
{ "ssn" : "987-65-4321" replace /[0-9]/ with("x") }
```

#### Output

```JSON
{ "ssn": "xxx-xx-xxxx" }
```
