On Sat, Jan 10, 2004 at 11:02:18PM +0000, Matthew Seaman wrote:
> On Sat, Jan 10, 2004 at 11:39:07PM +0100, Björn Andersson wrote:
> > On Sat, Jan 10, 2004 at 10:33:08PM +0000, Matthew Seaman wrote:
> > > On Sat, Jan 10, 2004 at 02:10:36PM -0800, Gary Kline wrote:
> 
> > > >         Folks,
> 
> > > >         Let's see if perl can do this one; it's as obscure a task
> > > >         as I've run into.  I have scores of files with:
> 
> > > >         A regular sentence, or phrase. then_one_containing_underscores_-
> > > >         between_each_word  Followed by another regular, space-delimited
> > > >         sentence.  Followed_by_another_string_with_underscaores.
> 
> > > >         Is there a perl way to get rid of the
> > > >         string_containing_underscores and leave the regular sntences??
> 
> > >     perl -pi.bak -e 's/\s+\w+_\w+\.?//;' filename
> 
> > If this occures more than once on a line we should have the line as this:
> >   perl -pi.bak -e 's/\s+\w+_\w+\.?//g;' filename
> 
> Good point.  Also, if the stuff_separated_by_underscores wraps around
> onto more than one line, then there may not be any leading whitespace:
> 
>     perl -pi.bak -e 's/\s*\w+_\w+\.?//g;' filename
> 

        The lines do indeed wrap so this does the job on a test file.
        I do have the re-exp book but this one is far ovr my head.
        What do the "\s*" mean, and also thr "\.?/" ?

        Man, I'd never have gotten this one; at least not in *one*
        lines:-)  Wow.  

        thanks to everyone,

        gary


-- 
   Gary Kline     [EMAIL PROTECTED]   www.thought.org     Public service Unix

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to