arrays - Restrict string split between particular values javascript -
i have string
var str = "error,#ffffff,won,25,[{\"color\":\"#7ac1de\",\"from\":\"10\",\"to\":\"60\"}]"
i splitting string based on comma (',') in string. need split string out affecting comma inside [{\"color\":\"#7ac1de\",\"from\":\"10\",\"to\":\"60\"}]
.
so expected output ['error', '#ffffff', 'won', '25', '[{"color":"#7ac1de","from":"10","to":"60"}]']
.
i tried many ways not working. please me.
something ?
var str = "error,#ffffff,won,25,[{\"color\":\"#7ac1de\",\"from\":\"10\",\"to\":\"60\"}]"; var split = str.split(/,(?![^{]*})/); console.log(split);
Comments
Post a Comment