JavaScript String to Title Case (capitalize words)
function toTitleCase(string)
{
// \u00C0-\u00ff for a happy Latin-1
return string.toLowerCase().replace(/_/g, ' ').replace(/\b([a-z\u00C0-\u00ff])/g, function (_, initial) {
return initial.toUpperCase();
}).replace(/(\s(?:de|a|o|e|da|do|em|ou|[\u00C0-\u00ff]))\b/ig, function (_, match) {
return match.toLowerCase();
});
}