I am looking for a regex to split a string containing ().
This is what I have
String regex = "(?=\\()|()"
The first part is correct so that it starts with the “(“. I need the second part to end on the “)”, but if there is a number after the “)” it need to end on the number.
example
Fe2(CH3)2(CH2O)(CH3)
This needs to split into
Fe2
(CH3)2
(CH2O)
(CH3)
The number after the “)” can be either a single or double digit.
I also needs to split Fe(C5H5)2O4(CH3) for example into
Fe
(C5H5)2
O4
(CH3)
Updated, the new logic: match either some letter chars or something parenthesized, followed by optional digits.