2019-06-13
javascript split string on space or on quotes to array
stackoverflow
Question
var str = 'single words "fixed string of words"';
var astr = str.split(" "); // need fix

i want the array to be like: single, words, fixed string of words.

Answer
1
str.match(/\w+|"[^"]+"/g)

//single, words, "fixed string of words"
javascript split string on space or on quotes to array
See more ...
Related Questions
Related Documents