Xref: utzoo comp.emacs:8998 comp.lang.perl:2255 Path: utzoo!utgpu!watserv1!watmath!att!rutgers!usc!jarthur!bridge2!mdb From: mdb@ESD.3Com.COM (Mark D. Baushke) Newsgroups: comp.emacs,comp.lang.perl Subject: Re: ALL CAPS-->Mixed case converter? Message-ID: Date: 1 Sep 90 18:15:21 GMT References: <3245@nems.dt.navy.mil> Sender: news@bridge2.ESD.3Com.COM Followup-To: comp.emacs Organization: 3Com Corp., Mountain View, CA. Lines: 36 In-reply-to: science@nems.dt.navy.mil's message of 1 Sep 90 13:06:34 GMT On 1 Sep 90 13:06:34 GMT, in article <3245@nems.dt.navy.mil> posted to comp.emacs, science@nems.dt.navy.mil (Mark Zimmermann) writes: Mark> does anybody have (a pointer to) an Emacs way to convert ALL CAPITAL Mark> LETTER TEXT into nice mixed-case text? There are obviously many Mark> degrees of sophistication in doing this; I'd like to be able to give Mark> the system a file of words to be capitalized and/or words to be Mark> lowercased and/or words to be all caps (NASA, USA, etc.), to Mark> customize, and it should try to find and capitalize the first word of Mark> each sentence. Any suggestions?? Is this better done in C or awk Mark> than in Emacs?? Tnx for help! - ^z - science@nems.dt.navy.mil The perl script after my .signature was posted to comp.lang.perl some time ago. With a little work it should be possible to add an exception list for some words like NASA, USA, etc. to be output in all caps. Enjoy! -- Mark D. Baushke mdb@ESD.3Com.COM #!/usr/bin/perl # This program copies its input to STDOUT, converting uppercase characters # to lowercase, except the first letter of each sentence and the word 'I'. # DEFINITION: a 'sentence' begins with an alphanumeric and ends at the end # of the input file or at the first terminator (period, question mark, or # exclamation point) which is followed by white space. $/ = "\177"; # do not split the input into lines $_ = <>; # read the entire input s/(\w)(([^.?!I]+|[.?!]+\S|\BI|I\B)+)/($a=$2)=~tr|A-Z|a-z|,$1.$a/eg; print; # print the results