At 4:59 PM -0700 8/15/03, Charles Jolley <[EMAIL PROTECTED]> wrote:
On Friday, August 15, 2003, at 4:38 PM, Jonathan Levi MD wrote:
@myfile=<STDIN>;
foreach $s (@myfile){
        $s=~s/([A-Z][a-z]?)([0-9]+)/$1\\sub $2\\nosupersub /g;

A safer way to do this would be:


$s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\} /g;

Thank you; I appreciate the point. (One small correction: the right curly brace in front of the /g makes the space redundant; in fact the space is now copied (incorrectly) into the text, so the replacement should properly be


$s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;

Patrick has sent me a sample file offline. In addition to the subscript requirements, a final + or - must be made superscript (also ++? --? +3? 3+ etc.)

As a result, the perl script has to be amended:

#!/sw/bin/perl
# dochemsubcripts.pl -- perl script to sniff out molecular formulas in an
# RTF file; insert subscript tags for the numbers; and superscript
# tags for a terminal +/-. JL 8/2003

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

Jonathan


--------------------------------------------------- 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