CFLib.org – Common Function Library Project

varNameToText(str)

Last updated January 07, 2009

author

Tony Felice

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Converts a camel-case or underscored var name to plain text.

Return Values:
Returns a string.

Example:

<cfoutput>#varNameToText("thisIsTheVarName")#</cfoutput>

Parameters:

Name Description Required
str String to parse. Yes

Full UDF Source:

<!---
 Converts a camel-case or underscored var name to plain text.
 v2 mods by RCamden
 
 @param str      String to parse. (Required)
 @return Returns a string. 
 @author Tony Felice (sites@breckcomm.com) 
 @version 2, January 6, 2009 
--->
function varNameToText(str) {
    var words = "";
    var i = "";
    var output="";

    str = reReplace(str,"([.^[:upper:]])", " \1","all");
    str = reReplace(str,"([.^_])", " ","all");
    words = ListToArray(str, " ");    
    for(i=1; i LTE (ArrayLen(Words)); i=i+1){
        words[i] = ucase(mid(words[i],1, 1)) & mid(words[i],2, len(words[i])-1);
    }
    output = arrayToList(words, " ");        
    return output;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson