Change-case modifier

Learn how to change the case of string values.

This modifier changes the case of a string to a specified style, helping format strings consistently even when you don't control the input. For example, you can apply title case to properly capitalize a user's name in a welcome message.

Syntax

This modifier has the following syntax:

/*<value>*/ in /*<style>*/ case
Try in Playground

The /*<style>*/ is a literal word that specifies the case style and cannot be specified dynamically using expressions.

Here is a list of the supported styles:

StyleDescription
lowerChange all characters to lowercase. For example, "Hello World" becomes "hello world".
upperChange all characters to uppercase. For example, "Hello World" becomes "HELLO WORLD".
titleChange the first character of each word to uppercase, and all others to lowercase. For example, "Hello world" becomes "Hello World".
sentenceChange the first character of each sentence to uppercase, and all others to lowercase. For example, "Hello World" becomes "Hello world".

Parameters

These are the supported parameters:

value

The string for which to change the case.

Examples

Here is a basic example of how to ensure that a user's name is properly capitalized:

user's name in title case // John Doe
Try in Playground

To understand the difference between the title and sentence case, consider the following example:

"THE QUICK BROWN FOX" in title case // The Quick Brown Fox
Try in Playground

Now, compare it with the sentence case:

"THE QUICK BROWN FOX" in sentence case // The quick brown fox
Try in Playground

Note that the entire sentence is affected, not just the first word.