Contact Us 1-800-596-4880

capitalize

capitalize(text: String): String

Capitalizes the first letter of each word in a string.

It also removes underscores between words and puts a space before each capitalized word.

Parameters

Name Description

text

The string to capitalize.

Example

This example capitalizes a set of strings.

Source

%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")
}

Output

{
  "a": "Customer",
  "b": "Customer First Name",
  "c": "Customer Name",
  "d": "Customer Name"
}

capitalize(text: Null): Null

Helper function that enables capitalize to work with a null value.