Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by AnomalousMonk (Chancellor)
on Mar 21, 2014 at 20:09 UTC ( #1079349=note: print w/replies, xml ) Need Help??


in reply to How to avoid an alphabet and integer next to it in a string?

Maybe something like:

c:\@Work\Perl\monks>perl -wMstrict -le "my $Hn = qr{ H (?! [[:lower:]]) \d* }xms; my $not_Hn = qr{ (?! $Hn) }xms; ;; use constant FORMULA => 'HC6H5OHHg2HeBr3H'; ;; my $s = FORMULA; print qq{'$s'}; $s =~ s{ $Hn }''xmsg; print qq{'$s'}; ;; $s = FORMULA; my @elements = $s =~ m{ $not_Hn [[:upper:]] [[:lower:]]? \d* }xmsg; printf qq{'$_' } for @elements; " 'HC6H5OHHg2HeBr3H' 'C6OHg2HeBr3' 'C6' 'O' 'Hg2' 'He' 'Br3'

Replies are listed 'Best First'.
Re^2: How to avoid an alphabet and integer next to it in a string?
by piscean (Acolyte) on Mar 21, 2014 at 20:43 UTC
    Thanks! This helped too :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1079349]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-12-13 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (345 votes). Check out past polls.

    Notices?