import * from dw::core::Strings
output application/json
---
{
a: replaceAll("Mariano", "a" , "A"),
b: replaceAll("AAAA", "AAA" , "B"),
c: replaceAll(null, "aria" , "A"),
d: replaceAll("Mariano", "j" , "Test"),
}
DataWeave
replaceAll
replaceAll(text: String, target: String, replacement: String): String
Replaces all substrings that match a literal search string with a specified replacement string.
Replacement proceeds from the beginning of the string to the end.
For example, the result of replacing "aa"
with "b"
in the
string` "aaa"
is "ba"
, rather than "ab"
.
Introduced in DataWeave version 2.4.0.
Parameters
Name | Description |
---|---|
|
The string to search. |
|
The string to find and replace in |
|
The replacement string. |
Example
This example shows how replaceAll
behaves with different inputs.
Source
Output
{
"a": "MAriAno",
"b": "BA",
"c": null,
"d": "Mariano"
}
Json
replaceAll(text: Null, oldValue: String, newValue: String): Null
Helper function that enables replaceAll
to work with a null
value.
Introduced in DataWeave version 2.4.0.