True Sentence Case
This is not to be confused with "Title Case". Sentence case is capitalizing only the first word of the sentence; other words of the sentence remain unchanged.
The various articles and answers on Stackoverflow do not address the issues explained below: The most relevant (although 6 years old) is Convert string to sentence case in javascript but does not work.
A paragraph (or article) may include several sentences separated by full-stops ".".
I am looking for a "SentenceCase" code that should at least handle the cases described below.
The intent is to ONLY capitalize the first word (if applicable) and not to try to modify or try to correct the rest of the sentence text.
The function should address the following standard cases:
// 1. Simple sentence (no full-stop):
// ----------------------------------
// Original: this is a sentence
// Becomes : This is a sentence
// 2. Two or more sentences:
// -------------------------
// Original: first sentence. second sentence . third sentence.
// Becomes : First sentence. Second sentence . Third sentence.
// 3. Sentences starting with a single char:
// -----------------------------------------
// Original: a world of fun. a world of fun.
// Becomes : A world of fun. A world of fun.
// 4. Sentences starting with a word that has an in-between cap:
// -------------------------------------------------------------
// Original: kHz is a unit of measure. kPascal too.
// Becomes : kHz is a unit of measure. kPascal too.
// Original: iPads are sold by Apple. iTones are too.
// Becomes : iPads are sold by Apple. iTones are too.
// 5. Sentences starting with a special chars/words:
// -------------------------------------------------
// Original: https//: is the web address. www.stack.com is another website.
// Becomes : https//: is the web address. www.stack.com is another website.
// Original: .Net is a programming language. foo_bar is a variable it uses.
// Becomes : .Net is a programming language. foo_bar is a variable it uses.
// Original: string_length is a snake case type variable.
// Becomes : string_length is a snake case type variable.
// Original: abc@domain.net is my email. defgh@dmain.net is his.
// Becomes : abc@domain.net is my email. defgh@dmain.net is his.
// Original: concrete5 is an open-source content management system.
// Becomes : concrete5 is an open-source content management system.
// 6. Text inside quotes:
// ----------------------
// Original: "we should stay home" said the governor. 'we will' we answered.
// Becomes : "we should stay home" said the governor. 'we will' we answered.
// Original: "this ". was text in quotes
// Becomes : "this ". Was text in quotes
// 7. Sentences with Abbreviations:
// --------------------------------
// Original: reporting time is 09:00 a.m. and leaving at 05:00 p.m. every day.
// Becomes : Reporting time is 09:00 a.m. and leaving at 05:00 p.m. every day.
// 8. Short sentences with single words:
// -------------------------------------
// Original: organization
// Becomes : Organization
// Original: development.
// Becomes : Development.