UCFirst

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

Member Function Syntax

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

This function requires Lucee. Not supported on Adobe ColdFusion.

Argument Reference for the UCFirst function

string

Required: Yes

doAll

Required: No

doLowerIfAllUppercase

Required: No

Examples sample code invoking the UCFirst function


Basic usage

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

ucFirst("hello world!")

Expected Result: Hello world!


Capitalize all the words in string

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!


Handling of strings in all uppercase

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!


Fork me on GitHub