CFLib.org – Common Function Library Project

nameCase(string)

Last updated January 1, 2006

author

Jared Rypka-Hauer

Version: 2 | Requires: CF6 | Library: StrLib

Description:
This uses a simple example of regex processing to convert ALL UPPER CASE STRINGS to Name Case Strings using CF's built-in case processing technology in the regex functions.

Return Values:
Returns a string.

Example:

<cfoutput>#nameCase("JARED RYPKA-HAUER")#</cfoutput>

Parameters:

Name Description Required
string String to format. Yes

Full UDF Source:

<!---
 Converts an entire string to namecase (JARED RYPKA-HAUER becomes Jared Rypka-Hauer).
 
 @param string 	 String to format. (Required)
 @return Returns a string. 
 @author Jared Rypka-Hauer (jared@web-relevant.com) 
 @version 2, January 1, 2006 
--->
<cffunction name="nameCase" access="public" returntype="string" output="false">
    <cfargument name="name" type="string" required="true" />
    <cfset arguments.name = ucase(arguments.name)>
    <cfreturn reReplace(arguments.name,"([[:upper:]])([[:upper:]]*)","\1\L\2\E","all") />
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson