Skip to content

Instantly share code, notes, and snippets.

Last active July 7, 2017 11:28
What would you like to do?
Split string but keep delimiter
function split(string) {
return string.match(/\w+(?:\s\w+)*\W?/g)
console.log(split("string one, string two, thing three, four four."))
// ["string one,", "string two,", "thing three,", "four four."]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment