Repeating search with GREP
Repeating search with GREP
- Subject: Repeating search with GREP
- From: Blaine Wilson <email@hidden>
- Date: Thu, 27 Mar 2003 12:15:44 -0800
I'm stuck. (As an AS newbie that happens a lot...)
I'm trying to extract email addresses from a huge text document.
I've found a grep pattern that works quite well, but I just don't know how
to repeat the search. (We'll I've figured out how to repeat it, but it just
returns the same result over and over...I want it to move on to the next
address after the first hit.)
Would one of you be so kind as to bestow some insight? Thanks!
Here's what I have so far:
copy "" to theLines
tell application "Tex-Edit Plus"
-- use Tex-Edit to collect all lines containing the string
select character 0 of window 1
repeat
if (search window 1 for
"([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA
-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)" with whole words and
+class SRgp;) is false then
exit repeat
else
set theLines to (theLines & selection of window 1 & return)
end if
end repeat
select character 0 of window 1
-- if any lines were found, save them in a new window of Tex-Edit
if theLines "" then
--set theLines to text 1 thru ((length of theLines) - 1) of theLines
activate
make new document
set text of document 1 to theLines as string
else
display dialog "No occurences found." buttons {"OK"} default button
1 with icon 1
return
end if
end tell
Thanks for your help!
Blaine
_______________________________________________
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.