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?

try this:

var list = '"one","two","3,842","3,549","3,653","4,443","3,994","3,935"' var split = json.parse("[" + list + "]"); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -