• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
dd: position of text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Prev by Date: Re: Beep broken in 10.1.4?
  • Next by Date: Re: Date formatting
  • Previous by thread: dd: Palm Note Pad (Desktop 4.0)
  • Next by thread: Re: dd: position of text
  • Index(es):
    • Date
    • Thread