Given the following string of nested parentheses
a = "[[[][]]][[[][][]]]"
I am trying to find the pair of opening and closing brackets in a and label their positions with common IDs. For example, I am trying to create a vector of IDs that would look like this
b = c(1,2,3,3,4,4,2,1,5,6,7,7,8,8,9,9,6,5)
For example, here 1 and 2 in the vector b is corresponding to the pair of brackets and so on..
[[[][]]][[[][][]]]
1 1
[[[][]]][[[][][]]]
2 2
Any input in this regard is much appreciated.