http://www.perlmonks.org?node_id=369087

blue.monk has asked for the wisdom of the Perl Monks concerning the following question:

Howdy --

groff (-mm) takes:

THE QUICK BROWN FOX
jumped over the lazy dog
And turns it into this:
THE QUICK BROWN FOX jumped over the lazy dog
What I want use psed to turn it into this:
.H 
THE QUICK BROWN FOX
.BP
jumped over the lazy dog
In short anytime there's 2 or more CAPS work togather insert a .H (header) tag beofore and a .BP (paragraph break at the end of the CAP words.

Any ideas?
David

 editted by jeffa - formatting 

Replies are listed 'Best First'.
Re: Perl & Groff (psed)
by Abigail-II (Bishop) on Jun 23, 2004 at 16:15 UTC
    You mean something like this:
    s/([A-Z][A-Z\s]*[A-Z])\s*/.H\n$1\n.BP\n/g

    Abigail

Re: Perl & Groff (psed)
by gellyfish (Monsignor) on Jun 23, 2004 at 16:12 UTC

    You mean something like:

    perl -pi -e's/(^.*[A-Z]{2,}.*)$/.H\n$1\n.BP/' <files>
    ?

    /J\

Re: Perl & Groff (psed)
by blue.monk (Novice) on Jun 23, 2004 at 23:30 UTC
    Thanks to you both :-)