I'm using regex to get the indices of variables accessing pattern represented as string, for example:
string = "test[2][56].var1[4]"
The regex match result in the groups 2, 56, 4 captured.
matchGroups = ["2", "56", "4"]
The regex below works.
\[([^\.\]]+)\]
But I can't allow cases like:
"test.[3].var1"
or
"test[3]/"
I tried to limit the characters allowed before and after each group using the regex below:
[\]a-zA-Z0-9]\[([^\.\]]+)\]([\[a-zA-Z0-9])?
But some cases stopped working like the case "test[0].var7[3][4]"(4 is not captured).
I need help to make this work with all cases again(cases are in the link below).