Date: Sun, 11 Jan 2004 21:22:12 -0800 From: Gary Kline <kline@thought.org> To: Matthew Seaman <m.seaman@infracaninophile.co.uk>, Gary Kline <kline@thought.org>, FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: perl script question. Message-ID: <20040112052212.GA70559@tao.thought.org> In-Reply-To: <20040111115237.GA10388@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> <20040111013434.GC44177@tao.thought.org> <20040111115237.GA10388@happy-idiot-talk.infracaninophile.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 11, 2004 at 11:52:37AM +0000, Matthew Seaman wrote: > On Sat, Jan 10, 2004 at 05:34:34PM -0800, Gary Kline wrote: > > On Sat, Jan 10, 2004 at 11:02:18PM +0000, Matthew Seaman wrote: > > > > 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 "\.?/" ? > Thanks for your tutorial. Time to re-read Jeff Friedl's book. I'd forgotten some of perl's regex rules--specifically, 's' and 'w'; was headsratching what symbolized whitespace. Also did not realize the "\w+_" would match one-or-more underscores. To me, this is the genius of the expression. I have a 994 perl script called reflow that does an outstanding job of formatting std ASCII|8859-N text. I filter any essay thru a program, joinlines, and reflow before handing it off to OpenOffice. What reflow doesn't do is to put two spaces between sentences. That's on my to-hack list:) have a good one, 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?20040112052212.GA70559>