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
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:
Style | Description |
---|---|
lower | Change all characters to lowercase. For example, "Hello World" becomes "hello world". |
upper | Change all characters to uppercase. For example, "Hello World" becomes "HELLO WORLD". |
title | Change the first character of each word to uppercase, and all others to lowercase. For example, "Hello world" becomes "Hello World". |
sentence | Change 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
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
Now, compare it with the sentence case:
"THE QUICK BROWN FOX" in sentence case // The quick brown fox
Note that the entire sentence is affected, not just the first word.