I have a list of strings that look like:
Item Q55127831 (Acute nitrobenzene poisoning with transient (optional) amino-aciduria.) > setting P921 to Q114953 (poisoning)
I want to extract:
Acute nitrobenzene poisoning with transient (optional) amino-aciduria.
Where there could be internal parenthesis (optional) or not.
I use Python 3
I tried with Regex1 and Regex2 above:
import re
regExp1 = "\(([^)]+)\)"
regExp2 = "\$\{((?:\{[^\{\}]*\}|[^\{\}]*)*)\}"
str = "Item Q55127831 (Acute nitrobenzene poisoning with transient (optional) amino-aciduria.) > setting P921 to Q114953 (poisoning)"
x = re.search(regExp2, str)[1,-1]
print(x)
regExp1 give:
Acute nitrobenzene poisoning with transient (optional
regExp2 give:
none
Could you help if you have more suitable solution?
Thanks