"hello world"
-> ["hello", "world"]
"say \"hello world\""
-> ["say", "hello world"]
const s = "say \"hello world\""
const r = s.match(/"[^"]*"|[^\s"]\S*/g).map(m => m.replace(/^"|"$/g, ''))
console.log(r)
import re
s = "say \"hello world\""
r = []
for m in re.finditer('"([^"]*)"|[^\s"]\S*', s):
if m.group(1) is None:
r.append(m.group(0))
else:
r.append(m.group(1))
print(r)