CFLib.org – Common Function Library Project

SpaceCap(text)

Last updated September 20, 2002

author

Mark W. Breneman

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns a string with a space before each capital letter unless it is the first letter in the string. Handy if you need output a field name like "FirstName" in the format of "First Name".

Return Values:
Returns a string.

Example:

<CFSET RequiredField="FirstName">
<CFOUTPUT>
The <b>#spacecap(RequiredField)#</b> Field is Required.
</CFOUTPUT>

Parameters:

Name Description Required
text String to modify. Yes

Full UDF Source:

/**
 * Returns a string with a space before each capital letter.
 * 
 * @param text 	 String to modify. (Required)
 * @return Returns a string. 
 * @author Mark W. Breneman (Mark@vividmedia.com) 
 * @version 1, September 20, 2002 
 */
function SpaceCap(text) {
  return REReplace(text, "([.^[:upper:]])", " \1","all");
}
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