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

Capitalize the first letter?

LEGEND ,
Oct 25, 2007 Oct 25, 2007
Is there a way in CF to capitalize the first letter of a word?
5.6K
Translate
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
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
Translate
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
You can use RegEx which is much easier and cleaner.
Translate
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
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.

Translate
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
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!
Translate
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
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.
Translate
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