DEV Community

Discussion on: What’s your alternative solution? Challenge #39

Collapse
 
szabi profile image
szabi • Edited

Nice job for a RegExp :)

function getTheWord(text) {
  return text.match(/\w*/g).filter(x => !!x);
}

Will also search over multiple lines (\n) and will return numbers as well ('hello 333' => ['hello', '333']).