celticMcCaps(lastName)
Last updated December 5, 2010
Version: 2 | Requires: ColdFusion 5 | 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:
<cfoutput>
#celticMcCaps(last_name)#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| lastName | String to modify. | Yes |
Full UDF Source:
<cfscript>
/**
* 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;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
4 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)