I would like to turn this:
"a:1,b:2,c:3"
Into:
[['a', '1'],['b', '2'],['c', '3']]
CodePudding user response:
You could use the JavaScript split method here and do it twice. Something like the following:
let array = [];
let str = "a:1,b:2,c:3";
let splitStr = str.split(',');
splitStr.forEach(subStr => {
array.push(subStr.split(':'));
});