Thanks Dan, the top code version worked but not the bottom one. I also included a script to remove all "special characters" as well.
here is the code snippet:
var DeptName = ToTitleCase(Field("department"));
var exceptions = [ "a" , "an" , "the" , "for" , "and" , "at" , "by" , "of" , "on" , "to" , "with" ];
for (var e in exceptions)
{
var exception = exceptions[e];
DeptName = DeptName.replace(new RegExp("\\b" + exception + "\\b", "gi"), exception);
}
var specialChars = "!@#$^%*()+=-[]\/{}|:<>?,.";
for (var i = 0; i < specialChars.length; i++) {
DeptName = DeptName.replace(new RegExp("\\" + specialChars, "gi"), "");
}
switch (DeptName)
{
case "Dining & Catering":
case "Parent & Family Connections":
case "Department of Technology Leadership & Innovation":
break;
default:
DeptName = DeptName.replace("&", "and").replace("Dining and Catering", "Dining & Catering")
.replace("Parent and Family Connections", "Parent & Family Connections")
.replace("Department of Technology Leadership and Innovation", "Department of Technology Leadership & Innovation") ;
break;
}
return DeptName
Again, thanks so much Dan!
--------------
Tony Hayden
Xerox