dd: position of text
dd: position of text
- Subject: dd: position of text
- From: dave dowling <email@hidden>
- Date: Wed, 24 Apr 2002 22:23:16 -0400
a text function question for you AS gurus out there:
how can i get the position of a string in a text block? for instance:
set myTextBlock to "blah blah blah Lucy blah blah blah want a
treat? blah blah blah Lucy."
set myString to "Lucy"
i can get the string "Lucy" from myTextBlock as a list by using
(word 3 of myTextBlock as list) or something like that. but how do
i say to AS, "Give me the index of the word myString in the list
myTextBlock", where the result is "3", since the string "Lucy" is
the 3rd word in myTextBlock. furthermore, how do i distinguish
between the first iteration of the string "Lucy" and the 2nd one,
assuming i need to manipulate one but not the other?
also, consider this similar scenario:
set myURL to "
http://www.apple.com/macosx/"
set myString to "macos"
supposing i want to change the string "macosx" to the string
"macos9" in myURL. i'd like the position (index) of the letter to
be replaced (the letter 'x' in this case). how do i isolate a
string or character's index?
i know i could write a looping script that will locate the
string/char, but i'd like to know if there's an existing function
in AppleScript's stock library before i take this route. i didn't
see anything in the Language Guide, but maybe i missed something?
thanks.
dave dowling
free at last! how i found peace with God:
http://www.davedowling.com/steps.html
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.