MACSCRPT Archives

June 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Joe Barwell <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 7 Jun 2006 22:10:14 +1300
Content-Type:
text/plain
Parts/Attachments:
text/plain (61 lines)
Hello People,

I've been wrestling with a very basic regex problem, using Satimage
osax, os 10.3.9. Basically, I want to strip multiple blank lines
(i.e. carriage-returns), but leave the remaining text and single
carriage-returns, e.g. the data may look like this:

"



108.0
109.0
110.0

112.0
113.0


"

While the desired form may be this:

"108.0
109.0
110.0
112.0
113.0"

I eventually found I could work around it using the 'find text'
command, but I had thought it would be possible using the 'change'
command. Is there a simple method to which I'm seemingly blind, or is
the 'change' command limited when it comes to carriage-returns? For
example, I can't write "\\r{2,}", I think because that's
self-defeating, as there's only ever one CR in a given line... um, am
I getting slightly warm? Presumably "(^$){2,}" is the same?

Really not what I wanted, but I tried experimenting using 'change' to
first replace CRs with "x", but then trying to change "x{2,}" into ""
didn't seem to do anything at all--to the x's leading the reals,
never mind those afterward. :-? I've probably overlooked something
pretty basic, if not several somethings. :-\

Secondly, I find Satimage osax's behaviour unpredictable as regards
escaped characters. For example, "\\r" or "\\t" often seem to be
being treated as literals, instead of escaped special characters, but
I can't find a logical pattern as to where their use is
recognized/not. The docs. speak of using return and tab instead of
"\\r" and "\\t", but seem to imply that's only necessary for use
within parentheses?

Can anyone please point out my omission(s)?

Cheers!

Slow boat to poor Selyn

Selected from Ambrose Bierce's "Devil's Dictionary":
HUSBAND, n. -- One who, having dined, is charged with the care of the
plate.

ATOM RSS1 RSS2