ColdFusion UDF Library - Capitalize
December 16th, 2008
«« Back to ColdFusion Library
Category:
STRINGS
Description:
Converts a string to Proper Case Formatting
Parameters:
Returns:
(String) A new list.
Requires:
Sample Use:
Copy to Clipboard
Category:
STRINGS
Description:
Converts a string to Proper Case Formatting
Parameters:
- str (String, required)
The string you wish to Proper Case.
Returns:
(String) A new list.
Requires:
Sample Use:
Copy to Clipboard
function Capitalize(str){
var loop = 0;
var result = "";
var re = "[^[:alpha:]]([a-z])";
var start = 1;
str = LCase(str);
str = UCase(Left(str,1)) & Right(str,Len(str)-1);
result = REFindNoCase(re,str,start,true);
while (result.pos[1] and ArrayLen(result.pos) gt 1){
str = mid(str,1,result.pos[2]-1) & UCase(mid(str,result.pos[2],1)) & mid(str,result.pos[2]+1,Len(str)-result.pos[2]);
start = start+result.pos[1];
result = REFindNoCase(re,str,start,true);
}
return str;
};
// http://www.programmers.org/index.php/coldfusion-udf-library/?ckey=76&function=Capitalize



