[Solved] Explode string [ ]


Here’s one way with Javascript. You can split the string using regex. It can output an array and from there you can loop and assign the strings to the variables you need

const str = "zoneAdd[1][home][group]"
const strArr = str.replace(/[\[\]']+/g,' ').trim().split(' ')

const task = strArr[0] 
const id = strArr[1] 
const place = strArr[2] 
const type = strArr[3]
console.log({strArr, task, id,place,type})

solved Explode string [ ]