1

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"]
Stefano Piovesan
  • 1,185
  • 3
  • 19
  • 37

1 Answers1

0

There is a way to do it by Regex:

var rx = /("[^"]*")(?:[,$])/g
var a = s.match(rx)
Pavel Gatnar
  • 3,987
  • 2
  • 19
  • 29