function splitWords(str) {
return str.split(/\s+/);
}
splitWords(`Look at the stars
Look how they\tshine for you`);
// ['Look', 'at', 'the', 'stars', 'Look', 'how', 'they', 'shine', 'for', 'you']Character class escape: \d, \D, \w, \W, \s, \S
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.