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

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