i have an String object and i want to convert to List . in this list are List of maps .
String Object is :
def listOfmap = [[ip:'10.10.10.10',cronformat:'0 2,3,5 * * * *'],[ip:'20.20.20.20',cronformat:'0 */1 * * * *'],[ip:'30.30.30.30',cronformat:'15 * * * * *']]
and i used this code for convert :
listOfmap.eachMatch( /[\[]?([^\[\],]+)[,\]]?/ ){ a << it[ 1 ] }
and i want to result listOfmap[0] will be :
[ip:'10.10.10.10',cronformat:'0 2,3,5 * * * *']
but result is :
listOfmap[0] = [ip:'10.10.10.10'
listOfmap[1] = cronformat:'0 2
listOfmap[2] = 3
listOfmap[2] = 5 * * * *
please help me . tnx
Use this regex instead: [\[]?([^\[\]]+)\]]?
EDIT
To include also the [
square brackets use: ([\[]?[^\[\]]+\])