The function TITLECASE capitalizes each word in a String according to common English title conventions.
This function takes a String as input and capitalizes each space-separated word in the String according to the following rules.
- By default, all words are capitalized.
- The first and last words are always capitalized.
- Both parts of hyphenated words are capitalized.
- Capitalization in the original string remains unchanged to allow for capitalized acronyms such as "CXR". However, the following words are an exception.
- Articles such as "a", "an", and "the" are lowercased.
- Conjunctions such as "and", "but", "or", and "nor" are lowercased.
- Short prepositions such as "as", "at", "by", "for", "in", "of", "on", "per", "to", and "via" are lowercased.
- Abbreviations for the word versus such as "vs.", "vs", "v.", "v" are lowercased.
- The words "en", and "if" are lowercased.
Declaration
TITLECASE(input_string) -> title_cased_string
Parameters
input_string (type: string)
Any string.
Return Values
title_cased_string (type: string)
The input_string reformatted in Title Case.
Examples
When called with this string containing all lower case letters, each word is capitalized except for the article.
TITLECASE("this should be a title") -> "This Should Be a Title"
Even if the article was originally capitalized, it will be converted to lowercase in the final output.
TITLECASE("This Should Be A Title") -> "This Should Be a Title"
In the following example, the word "on" is normally considered a preposition that should be lowercase, however, the last word of the string will always be capitalized.
TITLECASE("title case is on") -> "Title Case is On"
If the original string contains any capitalization that doesn't have a specific exception like articles, conjunctions, and prepositions, then that capitalization remains. In this example, we include the acronym "CXR" for Customer Experience Runtime.
TITLECASE("Learn more about the customer experience runtime (CXR)") ->
"Learn More About the Customer Experience Runtime (CXR)"