How to add UCASE after a slash in coldfusion

Im outputing text from a db that is all uppercase example "ACCOUNTING/FUNDAMENTALS" and I need ColdFusion to only make the beginning letter Upper case as well as the beginning letter after a slash like this "Accounting/Fundamentals". The code below is an example of what I need but its not correct.
<!--- Might need logic like this ---, but not sure --->
<cfif COURSE_TITLE_FINAL CONTAINS "/">
    <cfset COURSE_TITLE_FINAL = UCase(Left(COURSE_TITLE_FINAL, 1)) & LCase(Right(COURSE_TITLE_FINAL, Len(COURSE_TITLE_FINAL)-1))>
    </cfif>

Open in new window

tribalboy3000Asked:
Who is Participating?
 
SidFishesCommented:
this is probably easier in a regex but this works

<cfset COURSE_TITLE_FINAL = "ACCOUNTING/FUNDAMENTALS">

<cfif find("/",COURSE_TITLE_FINAL)>
<cfset U1 = Ucase(Left(COURSE_TITLE_FINAL, 1))>
<cfset U2 = Ucase(left(Listlast(COURSE_TITLE_FINAL,"/"), 1))>
<cfset l1 = lcase(right(listfirst(COURSE_TITLE_FINAL,"/"),len(listfirst(COURSE_TITLE_FINAL,"/"))-1))>
<cfset l2 = lcase(right(COURSE_TITLE_FINAL,len(Listlast(COURSE_TITLE_FINAL,"/"))-1))>
 <cfset COURSE_TITLE_FINAL = u1 & l1 & "/" & u2 & l2>
</cfif>
<cfoutput>
  #COURSE_TITLE_FINAL#
</cfoutput>
0
 
Jones911Commented:
Can be done in one line but this will work.
<cfset COURSE_TITLE_FINAL = "ACCOUNTING/FUNDAMENTALS" />
<cfif COURSE_TITLE_FINAL CONTAINS "/">
	<cfset string = makeUpper(listGetAt(COURSE_TITLE_FINAL,1,"/")) & "/" & makeUpper(listGetAt(COURSE_TITLE_FINAL,2,"/")) />
</cfif>
<cfdump var="#string#"/>
 
 
<cffunction name="makeUpper" returntype="string">
	<cfargument name="mixedString" required="true" />
    <cfreturn ucase(left(lcase(arguments.mixedString),1)) &  right(lcase(arguments.mixedString),len(arguments.mixedString)-1) />
    
</cffunction>

Open in new window

0
 
tribalboy3000Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.