I have the following code and I’ve got the id and name value in its own square bracket as shown below. How can I access the value of id and name?
let data = "[[id=3, name=BOX-3, description=test, comment=test, locationId=5, capacity=null]];"
let id = data.match(/(?<=id=)d+(?=,)/g);
let name = data.match(/(?<=name=)[w|-]*/g);
console.log(data);
console.log(id);
console.log(name);
console.log(id.match(/(?<=[)[^][]*(?=])/g) );
//console.log(idVal);
2
Answers
You can destructure the result to get the match.