Re: dd: position of text
Re: dd: position of text
- Subject: Re: dd: position of text
- From: has <email@hidden>
- Date: Thu, 25 Apr 2002 16:47:21 +0100
dave dowling wrote:
>
how can i get the position of a string in a text block?
Scripting Additions' "offset of" command is pretty basic (case sensitive;
returns only first offset). You need to roll your own or use a third-party
solution; e.g. see stringLib on my website (link below). For example, the
following will return a list containing the start and end offsets of every
instance of "Lucy", ignoring case:
======================================================================
property stringLib : load script alias "[your path to stringLib here]"
set myTextBlock to "blah blah blah Lucy blah blah blah want a treat?
[NO-BREAK]blah blah blah Lucy."
set myString to "Lucy"
tell stringLib to listAllOffsets(myTextBlock, myString, {iCase:true})
--> {{16, 19}, {66, 69}}
======================================================================
>
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?
stringLib also contains several find-and-replace functions.
HTH
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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.