---
schema_version: "1"
id: 39d2890a0fe0a8b1a8de1f2e00bf4a42d571a07481e29452ea1f462941dca571
title: with
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-core-functions-with.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-core-functions-with
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e47d639bf703e9d9b0c049218e06a1e029a861a855a920955b9d5cc21d5fbd54
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# 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" }
```
