function capitalTitle(s) {
var preposiciones = [
'a','al','ante','bajo','cabe','con','contra','de','del','desde','durante',
'en','entre','hacia','hasta','mediante','para','por','según','sin',
'so','sobre','tras','versus','via','vs','las','los','y','x','o','ó'
];
s=capital(s);
var r='\\s+('+preposiciones.join("|")+')\\s+';
var reg=new RegExp(r, "ig");
s = s.replace(reg, function(match) {
return match.toLowerCase();
});
s=s.replace(/cxc/gi,'CxC');
s=s.replace(/cxp/gi,'CxP');
s=s.replace(/srl/gi,'SRL');
s=s.replace(/llc/gi,'LLC');
s=s.replace(/ars/gi,'ARS');
return s;
}
String.prototype.toTitleCase = function () {
return this.toLowerCase().replace(/[^\s|\'\-]+/g, function(word) {
return word.replace(/^./, function(first) {
return first.toUpperCase();
});
});
}
Comments