ucFirst

Transforms the first letter of a string to uppercase or the first letter of each word, and optionally lowercase uppercase characters.

ucFirst(string [, doAll] [, doLowerIfAllUppercase]) → returns string

Member Function Syntax

string.ucFirst([doAll] [, doLowerIfAllUppercase])

This function requires Lucee.  Not supported on Adobe ColdFusion, etc.

Argument Reference

string string
Required

doAll boolean

doLowerIfAllUppercase boolean

Examples
Sample code invoking the ucFirst function

Lucee 4.5+ Capitalizes the first character of the first word only.

ucFirst("hello world!")

Expected Result: Hello world!

Lucee 4.5+ Using the optional doAll parameter capitalizes the first character of all words. Word separators are: whitespace, period, parenthesis, or dash.

ucFirst("cfdocs.org is your (everyone's) resource for cf-related documentation!", true)

Expected Result: Cfdocs.Org Is Your (Everyone's) Resource For Cf-Related Documentation!

Lucee 4.5+ Using the optional doLowerIfAllUppercase parameter allows for intelligent capitalization of words in all caps.

ucFirst("CFDOCS.ORG YOUR (EVERYONE'S) RESOURCE FOR CF-RELATED DOCUMENTATION!", true, true)

Expected Result: Cfdocs.Org Your (Everyone's) Resource For Cf-Related Documentation!

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub