Skip to main content
Inspiring
October 25, 2007
Question

Capitalize the first letter?

  • October 25, 2007
  • 4 replies
  • 5575 views
Is there a way in CF to capitalize the first letter of a word?
    This topic has been closed for replies.

    4 replies

    Known Participant
    October 29, 2007
    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.
    Inspiring
    October 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!
    Inspiring
    October 27, 2007
    You can use RegEx which is much easier and cleaner.
    Inspiring
    October 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.

    Inspiring
    October 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