• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

5.1K

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

Votes

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.

Votes

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.

Votes

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!

Votes

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.

Votes

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
Resources
Documentation