javascript - JS - How to split a string with more commas than I want -
i have string list of items. items in list contain strings represent numbers.
var list = '"one","two","3,842","3,549","3,653","4,443","3,994","3,935"' i tried splitting so:
list.split(',') // result: [""one"", ""two"", ""3", "842"", ""3", "549"", ""3", "653"", ""4", "443"", ""3", "994"", ""3", "935""] which not intended.
i like:
["one","two","3,842","3,549","3,653","4,443","3,994","3,935"] // or better: ["one", "two", 3842, 3549, 3653, 4443, 3994, 3935] how correctly split string array above?
var list = '"one","two","3,842","3,549","3,653","4,443","3,994","3,935"' var split = json.parse("[" + list + "]");
Comments
Post a Comment