Capitalize first letter following colon and ?: Javascript
I'd like to capitalize the first letter following a colon or an ? in javascript.
Ex. Coregulation: an int开发者_开发知识库egrative analysis --> Coregulation: An integrative analysis
Or: Coregulation? an integrative analysis --> Coregulation? An integrative analysis
I'd like to make the replacement during the body onload, which I already use to make some other replacements. Ex.
function myscript() {
document.body.innerHTML = document.body.innerHTML.replace(/\.\s\,/g,\"\.\,\"); document.body.innerHTML = document.body.innerHTML.replace(/\s\./g,\"\.\"); document.body.innerHTML = document.body.innerHTML.replace(/\.\(/g,\"\. \(\");
}
Does anybody would know how to do this?
Thanks!
var regex = /([:\?]\s+)(.)/g;
function correctify(full, prefix, letter){
return prefix + letter.toUpperCase();
}
document.body.innerHTML = document.body.innerHTML.replace(regex, correctify);
精彩评论