Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jan 2004 01:34:51 -0000
From:      Gary Kline <kline@thought.org>
To:        Matthew Seaman <m.seaman@infracaninophile.co.uk>, FreeBSD Mailing List <freebsd-questions@freebsd.org>, Gary Kline <kline@thought.org>
Subject:   Re: perl script question.
Message-ID:  <20040111013434.GC44177@tao.thought.org>
In-Reply-To: <20040110230218.GA5347@happy-idiot-talk.infracaninophile.co.uk>
References:  <20040110221036.GA44130@tao.thought.org> <20040110223308.GA4881@happy-idiot-talk.infracaninophile.co.uk> <20040110223907.GA16659@Uruk-Hai.Sanitarium.mine.nu> <20040110230218.GA5347@happy-idiot-talk.infracaninophile.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
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     kline@thought.org   www.thought.org     Public service Unix



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040111013434.GC44177>