CFLib.org – Common Function Library Project

varNameToText(str)

Last updated January 6, 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;
}
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