Capitalize the first letter?

LEGEND ,
Oct 25, 2007 Oct 25, 2007

Copy link to clipboard

Copied

Is there a way in CF to capitalize the first letter of a word?

Views

4.7K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 25, 2007 Oct 25, 2007

Copy link to clipboard

Copied

One way is using string functions. Left() to grab the first letter and UCase() to capitalize it. You can use Right() and Len() to grab the rest of the word.

You can see an example of something similar at cflib.org. But read the usage on how it operates if you pass multiple words.
http://www.cflib.org/udf.cfm?ID=9

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 27, 2007 Oct 27, 2007

Copy link to clipboard

Copied

You can use RegEx which is much easier and cleaner.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 27, 2007 Oct 27, 2007

Copy link to clipboard

Copied

Both methods work. While I would probably choose regex myself, I know not everyone feels comfortable with them. They're certainly not as intuitive as string functions. Use whichever you feel most comfortable with. Though regex are very powerful and well worth learning.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 27, 2007 Oct 27, 2007

Copy link to clipboard

Copied

cf_dev2 wrote:
> One way is using string functions. Left() to grab the first letter and
> UCase() to capitalize it. You can use Right() and Len() to grab the rest of
> the word.
>
> You can see an example of something similar at cflib.org. But read the usage
> on how it operates if you pass multiple words.
> http://www.cflib.org/udf.cfm?ID=9
>

Perfect. Thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 29, 2007 Oct 29, 2007

Copy link to clipboard

Copied

LATEST
Not in CF, but if all you want is to capitalize the first letter in an html output, you could try the CSS function below :

.title:fisrt-letter {text-transform: capitalize}

and apply the ".title" style to you div/span.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines