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

next in thread | previous in thread | raw e-mail | index | archive | help

--cNdxnHkX5QqsyA0e
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jan 10, 2004 at 11:39:07PM +0100, Bj=F6rn 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

	cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--cNdxnHkX5QqsyA0e
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD4DBQFAAIR6dtESqEQa7a0RAorPAJ9ggpAo0t9mB4b4TvNGcr6sD159XQCWMuXT
0D+QPS2Pr52C0573mSwq4w==
=0O18
-----END PGP SIGNATURE-----

--cNdxnHkX5QqsyA0e--



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