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>
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).
will also remove the H from HgS
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.
A Programming Language, 1962
Programming the 1900 series in COBOL, 1974
Algorithms + Data Structures = Programs, 1976
The C Programming Language, 1978
System V - Interface definition, 1986
Z80 Assembly Language Programming, 1979
TheSOURCE User's Manual, 1979
The C Primer, 1983
Interactive Fortran 77, A Hands on Approach, 1984
Perl.1 man page, 1991
Results (62 votes),