Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141921

Splitting end of text at period creates empty string

$
0
0

Given the following text

var text="unicorns! and rainbows? and, cupcakes.Hello this is splitting by sentences. However, I am not sure.";

I want to split at every period, there is a period at the end of the sentence and it splits it into an empty string as shown.

(4) ["unicorns! and rainbows? and, cupcakes", "Hello this is splitting by sentences", " However, I am not sure", ""]

What is a good way to split at the period using . but accounting for the end of the text?


Viewing all articles
Browse latest Browse all 141921

Trending Articles