in reply to Regexps for Parsing Brackets in Chemical Formulae

I wish you had provided some more sample data for me to play with, because I am not very farmiliar with chemical formulas but the following should do the trick:

1 while $formula =~ s/\(([^()]+)\)(\D|$)/$1$2/g; 1 while $formula =~ s/\(([^()]+)\)(\d)/$1x$2/e;
In the first line we are replacing any parens and their contents (which may not include parens) if followed by a non number with just the contents $1 and the non number $2. The |$ is to get a paren as the last character of a line.

In line 2 we find parens followed by a number and multiply them out.

-monkfish (The Fishy Monk)