I am trying to extract a string inside nested brackets and process them.
Say I have a line
string = "(A((B|C)D|E|F))"
According to the answer in Extract string inside nested brackets
I can extract the string inside the enclosed brackets, but for my case it is different since I have "D"brackets at the end, so this is the result of the code. He looks so far from my desired exit
['B|C', 'D|E|F', 'A']
This is my desired result.
[[['A'],['B|C'],['D']], [['A'],['E|F']']] # '|' means OR
Do you have any recommendation whether to implement it with a regular expression or just run the entire specified string?
Thus, this can lead to my final result, i.e.
"ABD"
"ACD"
"AE"
"AF"
At this point I will use itertools.product