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

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