– Common Function Library Project

camelToSpace(str [, capitalize])

Last updated March 8, 2010

Version: 0 | Requires: ColdFusion MX | Library: StrLib

Rated 2 time(s). Average Rating: 4.5

This is not about furry puppets in a rocket ship, but a function that takes a camel cased string and returns it lower-cased with spaces between the words. Comes in handy if you want to generate human readable captions from (camel cased) table column names.

Return Values:
Returns a string


view plain print about
<cfset str='aCamelCasedVariable'>

a very fancy column name 
id column


Name Description Required
str String to use Yes
capitalize Boolean to return capitalized words No

Full UDF Source:

view plain print about
 * Breaks a camelCased string into separate words
 * 8-mar-2010 added option to capitalize parsed words Brian Meloche
 * @param str      String to use (Required)
 * @param capitalize      Boolean to return capitalized words (Optional)
 * @return Returns a string 
 * @author Richard ( 
 * @version 0, March 8, 2010 

function camelToSpace(str) {
    var rtnStr=lcase(reReplace(arguments.str,"([A-Z])([a-z])","&nbsp;\1\2","ALL"));
    if (arrayLen(arguments) GT 1 AND arguments[2] EQ true) {
        rtnStr=uCase(left(rtnStr,1)) & right(rtnStr,len(rtnStr)-1);
return trim(rtnStr);
blog comments powered by Disqus


Latest Additions

CF Ninja CF Ninja added
14 day(s) ago

Stephen Withington Stephen Withington added
14 day(s) ago

Adam Cameron Adam Cameron added
a while ago

Ray Ford Ray Ford added
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 48 time(s)

Barney Boisvert indentXml
Rated 5.0, 12 time(s)

Rachel Lehman deAccent
Rated 5.0, 9 time(s)

Darwan Leonardo Sitepu splitNumber
Rated 5.0, 8 time(s)

Created by Raymond Camden / Design by Justin Johnson