Javascript RegExp for splitting text into sentences and keeping the delimiter

You need to use match not split. Try this. var str = “I like turtles. Do you? Awesome! hahaha. lol!!! What’s going on????”; var result = str.match( /[^\.!\?]+[\.!\?]+/g ); var expect = [“I like turtles.”, ” Do you?”, ” Awesome!”, ” hahaha.”, ” lol!!!”, ” What’s going on????”]; console.log( result.join(” “) === expect.join(” “) ) … Read more