Skip to main content
Inspiring
Oct 25, 2007 3:41 PM UTC
Question

Capitalize the first letter?

Is there a way in CF to capitalize the first letter of a word?
    This topic is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    Known Participant
    Oct 29, 2007 1:34 PM UTC
    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
    Inspiring
    Oct 27, 2007 6:40 PM UTC
    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
    Inspiring
    Oct 27, 2007 5:20 PM UTC
    You can use RegEx which is much easier and cleaner.
    Translate
    Inspiring
    Oct 27, 2007 5:26 PM UTC
    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
    Inspiring
    Oct 25, 2007 4:11 PM UTC
    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