How to split in javascript this string
s = "Shares Mil,"6,143","6,225","6,315"
in this array:
["6,143", "6,225", "6,315"]
s.split(',')
doesn't work because gives:
["6", "143", "6", "225", "6", "315"]
How to split in javascript this string
s = "Shares Mil,"6,143","6,225","6,315"
in this array:
["6,143", "6,225", "6,315"]
s.split(',')
doesn't work because gives:
["6", "143", "6", "225", "6", "315"]
There is a way to do it by Regex:
var rx = /("[^"]*")(?:[,$])/g
var a = s.match(rx)