Solved

Change case of a string after a space

Posted on 2013-11-20
3
274 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:earwig75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 39663253
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>
0
 

Author Comment

by:earwig75
ID: 39663294
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
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 39663306
<cfset theName = "BOB MATHEW ROBERTSON">
<cfloop index="word" list="#theName#" delimiters=" ">
   <cfif len(word) gt 1>
       #ucase(left(word,1))##lcase(right(word,len(word)-1))#
    <cfelse>
        #ucase(word)#
    </cfif>
</cfloop>
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question