WeCodeThings Library
Library of code bits
Glossary    Contact Us
Need a web designer? visit WeCodeThings.Com for more details
Search  
   
Browse by Category


WeCodeThings Library .: ColdFusion .: ColdFusion Initcap Capitalize the first letter of each word



ColdFusion Initcap Capitalize the first letter of each word

If you've ever used Oracle, the Initcap function comes in quite handy. This ColdFusion function can be thrown in a cfc. It returns a capitalized letter for the first letter of each word that is passed into the function. Its really nice to use when displaying someones name that is being pulled from a database that is has all caps or something.  It can also be useful for using it before you insert form data into the database.

  1. <cffunction name="initCap" access="public" output="false" returntype="String" hint="I capitalize the first letter of every word group">
  2.         <cfargument name="inputString" required="false" type="String" default="" />
  3.         <cfreturn rereplace(lcase(arguments.inputString), "(\b\w)", "\u\1", "all") />
  4. </cffunction>


How helpful was this article to you?

Related Articles

article SQL Count Number of Times a Word or Number Appears in ONE Field or Column
This Query has become my favorite query to...

(No rating)  6-5-2009    Views: 1187   
article ColdFusion Insert Data Statement Into a Table using ColdFusion CFC CFQueryParam
Be sure that when you type out the field...

  4-28-2009    Views: 1588   
article How to display Random Quote using ColdFusion and the RandRange Function
<!--- Be sure to change...

(No rating)  4-7-2009    Views: 807   

User Comments

Add Comment
No comments have been posted.




.: Powered by Lore .:Code by WeCodeThings Website Design and Development