Counts the number of sentences in a string. Sentences are defined as sequences of text ending with ., !, or ? followed by whitespace or end of string. Text without any sentence-ending punctuation is considered to be a single sentence.
String input to count sentences from
Number of sentences in the string
countSentences('Hello world! How are you?'); // 2 Copy
countSentences('Hello world! How are you?'); // 2
Counts the number of sentences in a string. Sentences are defined as sequences of text ending with ., !, or ? followed by whitespace or end of string. Text without any sentence-ending punctuation is considered to be a single sentence.