How do I get an array like this
[
0: [ "first", "value", "1" ],
1: [ "second", "value", "2" ],
2: [ "third", "value", "3" ]
]
or even better
[ "first", "value", "1", "second", "value", "2", "third", "value", "3" ]
from the string
"first.value[1].second.value[2].third.value[3]"
relying on a single RegEx.exec() run?
I tried this:
regex = /\.*([\w]+)\.([\w]+)\[([\d]*)\]/g;
var str = "first.value[1].second.value[2].third.value[3]";
result = regex.exec(str);
but I can not get the sub-capturing-groups (like in the first example).
PS - I would like to get the regular expressions for both type of results (flat array or nested arrays)