celticMcCaps(lastName)
Last updated December 05, 2010
Version: 2 | Requires: CF5 | Library: StrLib
Description:
You can use this function whenever you output an undetermined list of last names in order to be sure that the McNamaras and the MacGreggors names are output correctly.
Return Values:
Returns a string.
Example:
<cfset last_name = "mcnamara">
<cfoutput>
#celticMcCaps(last_name)#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
lastName | String to modify. | Yes |
Full UDF Source:
/**
* Proper capitalization for us Mc's and Mac's!
* v2 by Kris Korsmo
*
* @param lastName String to modify. (Required)
* @return Returns a string.
* @author Kyle McNamara (kyle@themacs.info)
* @version 2, December 5, 2010
*/
function celticMcCaps(lastName) {
var capLastName = lCase(lastName);
if (left(lastName,2) eq "Mc") {
capLastName = uCase(left(lastName,1)) & lCase(mid(lastName,2,1)) & uCase(mid(lastName,3,1)) & lCase(right(lastName,len(lastName)-3));
return capLastName;
}
else if (left(lastName,3) eq "Mac") {
capLastName = uCase(left(lastName,1)) & lCase(mid(lastName,2,1)) & lCase(mid(lastName,3,1)) & uCase(mid(lastName,4,1)) & lCase(right(lastName,len(lastName)-4));
return capLastName;
}
else if (left(lastName,2) eq "O'") {
capLastName = uCase(left(lastName,1)) & "'" & uCase(mid(lastName,3,1)) & lCase(right(lastName,len(lastName)-3));
return capLastName;
}
else return lastName;
}
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