Capitalization for us Mc’s and Mac’s!

Needed to capltalize Mc’s and Mac’s? Here’s a quick function for it…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
* Proper capitalization for us Mc's and Mac's!
*/
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 return lastName;
}

Found at http://cflib.org/udf.cfm?ID=896

Leave a Reply