I want to extract and locate the words within all brackets/braces in a sentence, but I am currently having trouble with overlapping brackets. e.g.:
[in]: sentence = '{ia} ({fascia} antebrachii). Genom att aponeurosen fäster i armb'
[in]: pattern = r"\[([^\[\]()]+?)\]|\(([^\[\]()]+?)\)|\{([^\[\]()]+?)\}"
[in]: [(m.start(0), m.end(0), sentence[m.start(0) : m.end(0)]) for m in re.finditer(pattern, sentence)]
[out]: [(0, 4, '{ia}'), (5, 27, '({fascia} antebrachii)')]
It should identify 3 instances and correct indices. Any advice pls?