On Wed, 1 Aug 2007, Emmanuel <[log in to unmask]> wrote:
>At 9:54 PM +0100 7/29/07, John Delacour wrote:
>>At 2:22 pm +0100 29/7/07, I wrote:
>>
>>>set _string to change "\\t([^A][^A][^A])\\t$" into "\\1" in _string
>>>with regexp
>>
>>or
>>change "\\t([^A]{3})\\t$" into "\\1"
>
>Unless I'm missing something, and in case it's not clear for the OP,
>this does not fit his request. He wants to match \tABC\t, the regexps
>above don't.
Thank you, Emmanuel. I'll take your word for it, seeing as I'm stuck
in bed with the 'flu & unable to access my work computer to put JD's
permutations to the test.
Yes, I want to strip trailing tabs off lines of various
alpha-numerical combinations, including those that may end with A\t
(NB, not all lines end with a tab followed by a three-letter
combination, and a further tab--that is a method of "flagging" some
of my data for diverse purposes, with which I shall not detain you
here), but ignore (i.e. keep the trailing tabs of) only lines that
end with \tAAA\t.
The following does work, I just was seeking a second opinion, in case
I'd missed something tidier:
set s to change "\\tAAA\\t$" into "\\t#\\t" in s with regexp
set s to change "([^#])\\t$" into "\\1" in s with regexp
set s to change "\\t#\\t$" into "\\tAAA\\t" in s with regexp
There is, I suppose, a very slight chance someday of finding a hash
character somewhere in my data set, but it would be extraordinarily
unlikely to occur surrounded by tabs, so I s'pose it's safe enough.
Now that I think of it, another alternative would be simply to strip
all trailing tabs, but then put them back on the end of lines that
end with \tAAA. <shrug>
set s to change "\\tAAA$" into "\\tAAA\\t" in s with regexp
Thanks to all posters.
Cheers!
Joe
Selected from Ambrose Bierce's "Devil's Dictionary":
RECOLLECT, v. -- To recall with additions something not previously known.
|