Re: dd: position of text
Re: dd: position of text
- Subject: Re: dd: position of text
- From: JJ <email@hidden>
- Date: Thu, 25 Apr 2002 11:43:38 +0200
>
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"
You can get the _first_ "Lucy" using "offset of" command, from Standard
Additions:
offset of "Lucy" in myTextBlock
>
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?
It doesn't exist a "command", but you can manipulate strings (a basical
search-replace function) using AppleScript's text item delimiters:
set applescript's text item delimiters to "macosx"
set myURL to text items of myURL
set applescript's text item delimiters to "macos9"
set myURL to myURL as text
set applescript's text item delimiters to {""}
myURL
JJ
_______________________________________________
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.