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?

my $molform = <STDIN>; $molform =~ s/[^a-zA-G0-9]//g; my $molmass = new Chemistry::MolecularMass; my $mass = $molmass->calc_mass("$molform");
  • Comment on Re^3: How to avoid an alphabet and integer next to it in a string?
  • Download Code

Replies are listed 'Best First'.
Re^4: How to avoid an alphabet and integer next to it in a string?
by runrig (Abbot) on Mar 21, 2014 at 18:08 UTC
    $molform =~ s/[^a-zA-G0-9]//g;

    Just eliminate the Hydrogen:

    $molform =~ s/H\d*//g;
      It says Forbidden chars. No output at all!