Skip to content

Instantly share code, notes, and snippets.

@christiannaths
Last active June 3, 2018 19:25
Show Gist options
  • Save christiannaths/c25635c493e610316dd70718ff95a3b1 to your computer and use it in GitHub Desktop.
Save christiannaths/c25635c493e610316dd70718ff95a3b1 to your computer and use it in GitHub Desktop.
Split a template literal at word boundry
function w() {
arguments[0] = { raw: arguments[0] };
const str = String.raw(...arguments);
return str.match(/\b(\w+)\b/gm);
}
w`this is a string of words`
// => ["this", "is", "a", "string", "of", "words"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment