Re: Re(2): Re(2): Counting Words and Characters
Re: Re(2): Re(2): Counting Words and Characters
- Subject: Re: Re(2): Re(2): Counting Words and Characters
- From: Michelle Steiner <email@hidden>
- Date: Fri, 13 Jul 2001 11:03:46 -0700
On 7/13/01 10:50 AM, Arthur Cormack <email@hidden> wrote:
>
Thank you Michele. This too will work, even if you don't know what
>
word number 5 is.
>
(... it's pretty obvious actually)
>
... but if the pattern was not unique in the line being analysed -
>
say, if word 5 also occurred earlier, or later on in the line ... it
>
could cause some trouble, no? if word 1 was the same as word 5, for
>
example, and we looked for the offset, we snip in the wrong place.
>
Am I being too stubborn?
So, the problem is that you want to replace word five, regardless of what
it is, and do not want to replace any other instances of that word?
That's even easier, and I should have done that in the second iteration,
had I thought about it a bit longer.
set stringtochange to "The quick brown fox jumped over the dirty black
dog's head."
set {tid, text item delimiters} to {text item delimiters, space}
set listtochange to text items of stringtochange
set item 5 of listtochange to "leaped"
set newstring to listtochange as text
set text item delimiters to tid
newstring
--Michelle
----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------