in reply to Re: Re: Re: Re: Regexps for Parsing Brackets in Chemical Formulae
in thread Regexps for Parsing Brackets in Chemical Formulae
s/([A-Z][a-z]{0,2})(\d*)/ $count{$1} += $2 ? $2 : 1 '' /eg;
is cleaner. The (?:) was a unneeded left-off in my code and when you added the {0,2} modifier, the ? modifier became redundant. Or {2}? could be used instead of {0,2}.
Strangely for the golfers {,2} is not supported; it should be expected to be supported because {2,} is.
-- stefp
|
|---|