getNameInitials(str)
Last updated October 04, 2007
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Creates a sequence of initials based on an input name string. The UDF essentially takes the first characters of each word in the input string, capitalizes them and puts them together.
Return Values:
Returns a string.
Example:
<cfset name="John Alexander Smith"><br>
<cfoutput>Initials for #name# are #getNameInitials(name)#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
str | String to parse. | Yes |
Full UDF Source:
/**
* Extracts the initials of a name from long string.
*
* @param str String to parse. (Required)
* @return Returns a string.
* @author Anonymous (anonymous@gmail.com)
* @version 1, October 4, 2007
*/
function getNameInitials(str) {
var newstr = "";
var word = "";
var i = 1;
var strlen = listlen(str," ");
for(i=1;i lte strlen;i=i+1) {
word = ListGetAt(str,i," ");
newstr = newstr & UCase(Left(word,1));
}
return newstr;
}
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