String searching
String searching
- Subject: String searching
- From: "Steve Suranie" <email@hidden>
- Date: Mon, 19 Jan 2004 12:29:38 -0500
- Thread-topic: applescript-users digest, Vol 3 #2348 - 13 msgs
Does anyone have a snippet of code to do offset searches backwards and forwards from a certain point in a string?
For example if I have this code:
tell application "Internet Explorer"
Activate
OpenURL "
http://edition.cnn.com/" toWindow -1
with timeout of 3600 seconds
set theCode to (GetSource) as string
end timeout
set itemLocale to offset of "Pakistan" in theCode
end tell
the word pakistan appears at the 17,224 character in the string theCode - it's actually in this line
<a href=\"/2004/WORLD/asiapcf/01/18/pakistan.scientists.nukes/index.html\">Pakistan widens nuke probe</a>
What I would like to be able to do is search backwards from itemLocale of theCode to find the first instance of "<a href" and then to search forward from that point to find the first instance of "</a>" Basically I want to be able to pull the hyperlink associated with the word I am searching for.
Or if there is a simplier way of doing it that would be appreciated as well.
Thanks
Steve
_______________________________________________
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.