Re(2): Re(2): Counting Words and Characters
Re(2): Re(2): Counting Words and Characters
- Subject: Re(2): Re(2): Counting Words and Characters
- From: "Arthur Cormack" <email@hidden>
- Date: Fri, 13 Jul 2001 13:50:04 -0400
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?
... many convoluted thanks,
-arthur
email@hidden writes:
>
set stringtochange to "The quick brown fox jumped over the dirty
>
black
>
dog's head."
>
set wordtochange to word 5 of stringtochange
>
set newword to "leaped"
>
set beforesnip to (offset of wordtochange in stringtochange) - 1
>
set wordlength to length of wordtochange
>
set aftersnip to beforesnip + wordlength + 1
>
set newstring to text 1 through beforesnip of stringtochange &
>
newword &
>
text aftersnip through -1 of stringtochange