Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: How to avoid an alphabet and integer next to it in a string?

by piscean (Acolyte)
on Mar 21, 2014 at 17:57 UTC ( #1079314=note: print w/ replies, xml ) Need Help??


in reply to Re: 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?

Yes, this is what I was looking for. Thanks! I tried avoiding H in C6H9. It turned out to calculate C69 giving me a wrong result. Of course, I was foolish enough to try this.


Comment on Re^2: How to avoid an alphabet and integer next to it in a string?
Re^3: How to avoid an alphabet and integer next to it in a string?
by piscean (Acolyte) on Mar 21, 2014 at 18:02 UTC
    my $molform = <STDIN>; $molform =~ s/[^a-zA-G0-9]//g; my $molmass = new Chemistry::MolecularMass; my $mass = $molmass->calc_mass("$molform");
      $molform =~ s/[^a-zA-G0-9]//g;

      Just eliminate the Hydrogen:

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1079314]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-09-21 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls