Link to home
Start Free TrialLog in
Avatar of earwig75
earwig75

asked on

Change case of a string after a space

I have 2 variables, FirstName and LastName. These are always returned in CAPS. Sometimes the Firstname has a space and then a middle inital. So, the firstname might be something like BOB R.
On cfoutput I want to convert that to Bob R. Can someone assist? Basically, if there is a space and then another letter in the string I want the letter after the space to be uppercase as well.
Thank you.
Avatar of gdemaria
gdemaria
Flag of United States of America image

Something like this:

<cfset theName = "BOB MATHEW ROBERTSON">
<cfloop index="word" list="#theName#" delimiters=" ">
    #ucase(left(word,1))##lcase(right(word,len(word)-1))#
</cfloop>
Avatar of earwig75
earwig75

ASKER

Receiving error: "The 2 parameter of the Right function, which is now 0, must be a positive integer."

Sometimes the name is just : BOB

Sometimes it is BOB S
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial