I'm just about pulling my hair here. I have a function that I made (found and modified) To make text title case. The reason I use this function Instead of just capitalizing the first letter of every word is because there are many words That should not be capitalized.
The code that I have here works. Now all I need is for it to capitalize the first character of every sentence. So after it finished is the function, create a new function that will capitalize the first character of the new string. I just can't figure out how to do this in his driving me crazy. Thank you so much for all your help guys I appreciate it.
var TITLECASE = function (str, glue) {
glue = (glue) ? glue : ['a', 'and', 'as', 'at', 'but', 'by', 'for', 'if', 'in', 'is', 'it', 'my', 'nor', 'of', 'off', 'on', 'or', 'per', 'so', 'the', 'this', 'to', 'up', 'via', 'with', 'yet'];
return str.replace(/(\w)(\w*)/g, function (_, i, r) {
var j = i.toUpperCase() + (r != null ? r : "");
return (glue.indexOf(j.toLowerCase()) < 0) ? j : j.toLowerCase();
});
};