Re: similar strings
Re: similar strings
- Subject: Re: similar strings
- From: kai <email@hidden>
- Date: Tue, 10 Jan 2006 14:41:48 +0000
On 10 Jan 2006, at 11:58, some fruitcake wrote:
A slight speed bump could be achieved with a minor, front-end
modification...
... which rendered a later statement completely redundant. My
apologies for the noise - not to mention the sloppiness. :-)
--------
set s to "The answer on is now is the time for a party
with foxes and cows but no good men"
set l to "Now is the time for all good men to come to the
aid of the party while the quick brown fox jumps over the lazy dog.
How now brown cows but no good men"
set v to 1
set b to 1
set e to 1
set r to {}
set c to (count l) + 1
repeat
repeat while e < c and l's text b thru e is not in s
set e to e + 1
set b to b + 1
end repeat
repeat while e < c and l's text b thru e is in s
set r's end to b
set e to e + 1
end repeat
tell e - b to if it > v then
set v to it
set r to {b}
end if
if e is c then
if (count r) is 0 then return {0, ""}
repeat with i in r
set i's contents to l's text i thru (i + v - 1)
end repeat
return {v} & r
end if
set b to b + 1
end repeat
--> {21, "Now is the time for a", " cows but no good men"}
--------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden