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

# 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._
