function capitalizeFirstLetters(str) {
var reEachLine = /.*?\s[^\s\.]+\.\s/gi;
var reFirstLetter = /^[^a-z]*?([a-z])/gi;
var match = null;
var lines = [], line;
var from = 0, till = 0;
while(match = reEachLine.exec(str))
{
from = till;
till = match.index + match[0].length;
line = str.slice(from, till);
if (line.length > 0)
lines.push(line);
}
line = str.slice(till);
if (line.length > 0)
lines.push(line);
for (var i = 0; i < lines.length; i++) {
lines[i] = lines[i].replace(reFirstLetter, function(letter) {
return letter.toUpperCase();
});
}
var result = lines.join('');
if (result.length === str.length) {
return result;
}
return str;
}
97500cookie-checkJavascript: Capitalize all lines