I currently have this regular expression to split strings by all whitespace, unless it\'s in a quoted segment:
keywords = \'pop rock \"hard rock\"\'; keyword
I would like to point out I had the same regex as you,
/\w+|"[^"]+"/g
but it didnt worked on empty quoted string such as :
"" "hello" "" "hi"
so I had to change the + quantifier by *. this gave me :
str.match(/\w+|"[^"]*"/g);
Which is fine.
(ex: https://regex101.com/r/wm5puK/1)