---
schema_version: "1"
id: 56a5567d00c4fe2da44a46e353ea04675d87cf2d2aa45fe78dbf8d0c7ac74caf
title: mapString
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-strings-functions-mapstring.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-strings-functions-mapstring
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7bef1d1de4246287d826891718da93c2bc5139d494e36d8d10f56a8b868e60e8
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# mapString

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

## mapString(@StreamCapable text: String, mapper: (character: String, index: Number) -> String): String

Applies an expression to every character of a string.

_Introduced in DataWeave version 2.4.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 string to map.</p></td></tr><tr><td><p><code>mapper</code></p></td><td><p>Expression that applies to each character (<code>$</code>) or index (<code>$$</code>) of the <code>text</code> string and returns a string.</p></td></tr></tbody></table>

### Example

This example redacts sensitive data from a string.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{ balance: ("\$234" mapString if (isNumeric($)) "~" else $) }
```

#### Output

```Json
{
  "balance": "$~~~"
}
```

## mapString(@StreamCapable text: Null, mapper: (character: Nothing, index: Nothing) -> Any): Null

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

_Introduced in DataWeave version 2.4.0._
