in reply to
Re^2: How to avoid an alphabet and integer next to it in a string?
in thread How to avoid an alphabet and integer next to it in a string?
What about this?
$formula =~ s/H\d*//g;
The Problem with s/H\d*//g is that it will also remove the H from HgS (ok,, not organic chemistry, but you get the point).
One way to avoid that is to use a negative look-ahead:
<p>Or if you prefer the Unicode-y approach:</p>
will also remove the H from HgS
The first code says Forbidden chars again.
As far as which approach, don't worry about it. Just pick one (as long as it works).
Or simpler, H\d+. \d* will match *zero* or more digits, \d+ matches *one* or more.
update: oh, wait, ignore me. You need to knock out the H in (eg) NaOH, which doesn't have a digit after it.
I make decisions, and my brain carries them out
My brain makes the decisions, and I observe them (if I'm lucky)
I make some decisions, and my brain makes others
My spouse makes decisions and I and my brain carry them out
I wrote a program to relieve me and my brain from the burden of decision-making
The black-helicopter people project the decisions into my brain and then I do as ordered
Results (477 votes),