%dw 2.0
import * from dw::core::Strings
output application/json
---
{
"a" : capitalize("customer"),
"b" : capitalize("customer_first_name"),
"c" : capitalize("customer NAME"),
"d" : capitalize("customerName"),
"e" : capitalize("a*s_b’s")
}
DataWeave
capitalize
capitalize(text: String): String
Capitalizes the first letter of each word in a string.
The function treats every non-alphabetic character as a separator and replaces underscores with spaces. For example, capitalize("a*s_b’s")
results in "A*S B’S"
.
Parameters
Name | Description |
---|---|
|
The string to capitalize. |
Example
This example capitalizes a set of strings.
Source
Output
{
"a": "Customer",
"b": "Customer First Name",
"c": "Customer Name",
"d": "Customer Name",
"e": "A*S B’S"
}
JSON
capitalize(text: Null): Null
Helper function that enables capitalize
to work with a null
value.