Skip to main content
Inspiring
June 28, 2006
Answered

Make first left ucase

i have a support trouble ticket program that users will type their problems in a provided field and send the issue to us. we have an interface that lists out the issues... (now of course this is all cosmetic) sometimes the user starts the issue off with a lower case letter. is there a way to take that first letter and change it to ucase? i have tried many different things but they all fail. the only thing i am thinking now is to take the left 1 letter and ucase it , output that, then take the left most letter in another output and drop it and output the rest. there has to be a better way.
    This topic is closed to new replies. Start a new post to keep the conversation going.
    Dan_BracukCorrect answer
    Inspiring
    June 28, 2006
    ucase(left(yourvar,1)) gives you the first letter in upper case
    lcase(mid(yourvar, 2, len(yourvar) -1 )) gives you the rest in lower case

    If you don't know how to concatonate, this would be a good time to learn.

    5 replies

    June 29, 2006
    This is easy in CF...
    <CFSET Before = " this is typical user input. Note the extra leading and trailing whitespace. #Chr(13)##Chr(10)#">
    <CFSET After = REReplace (Before, "\s*(\S*.*\S)\s*", "\u\1")>

    <CFOUTPUT><pre>[#Before#] ---> [#After#]</pre></CFOUTPUT>

    Translate
    elDonricoAuthor
    Inspiring
    June 29, 2006
    mikerRoo,
    thanks, this was what i was talking about... i knew there was a way to do this rather than a concatonation... if you could, fill me in on the CHR(13) CHR(10)... what does this mean?
    Translate
    Participating Frequently
    June 29, 2006
    CHR(13) and CHR(10) would be the ASCII values for return and linefeed respectively. They are just explicitly being included in the string.

    Phil
    Translate
    Dan_BracukCorrect answer
    Inspiring
    June 28, 2006
    ucase(left(yourvar,1)) gives you the first letter in upper case
    lcase(mid(yourvar, 2, len(yourvar) -1 )) gives you the rest in lower case

    If you don't know how to concatonate, this would be a good time to learn.
    Translate