I have added one more line (last one) to the subscript/superscript macro that has been created by many contributors to this list. It seems to take care of the following chemical formulas:
Ca2+
S2-
OH1-
6H2O
CuCl2
Al2O3
Cu2+
CuCl31-
Al2(SO4)3
Al3(SO4)3(OH)3
Al2(SO4)3OH1-
AlOH2+
Al2(SO4)3(OH)21-
6Ca2+
6S2-
SO42-
6SO42-
6Cr2O72-
Cu(H2O)62+
Ni(CN)42-
Fe4[Fe(CN)6]3
B4O104-


The Perl macro that operates on the above formula is:
#!/usr/bin/perl
#Nisus Macro Block
#source front
#destination new
#Send Text as RTF
#End Nisus Macro Block

@myfile=<STDIN>;
foreach $s (@myfile){
         $s=~s/([A-Z][a-z]?[0-9]*)([0-9][+-])/$1\{\\super $2\}/g;
        $s=~s/([A-Z][a-z]?)([0-9]*[+-])/$1\{\\super $2\}/g;
        $s=~s/\)([+-])/\)\{\\super $1\}/g;
        $s=~s/\)([0-9]+)([0-9][+-])/\)\{\\sub $1\}{\\super $2\}/g;
        $s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;
        $s=~s/\)([0-9]+)/\)\{\\sub $1\}/g;
         $s=~s/\]([0-9]+)/\]\{\\sub $1\}/g;
        print $s;
}

# end of script

--
Patrick Gormley
Lapeer East High School
Lapeer MI 48446
http://chem.lapeer.org
---It's an Amino World


--------------------------------------------------- The Nisus Interactive List [EMAIL PROTECTED]

Searchable archives:
http://www.mail-archive.com/nisus-interactive%40nisus.com/

To unsubscribe from this list please send a message with "unsubscribe
nisus-interactive" in the body of the email to [EMAIL PROTECTED]




Reply via email to