I would expect this line of JavaScript:
\"foo bar baz\".match(/^(\\s*\\w+)+$/)
to return something like:
[\"foo bar baz\",
try using 'g':
"foo bar baz".match(/\w+/g)