I want to split a string of text into an array of sentences while preserving the punctuation marks.
var text = 'This is the first sentence. This is another sentence! This is a question?'
var splitText = text.split(/\b(?<=[.!?])/);
splitText
=> ["This is the first sentence.", "This is another sentence!", "This is a question?"]
How can I ensure that all sentences are split after the punctuation marks so that splitText returns the desired output?
["This is the first sentence.", "This is another sentence!", "This is a question?"]