split punctuation as separate word js code example Example: how to split by words and punctuation in javascript string.split(/\s*\b\s*/)