Wow. This is a bigger deal than I thought. I should also have mentioned that I 
need to document the steps and pass them along to a coworker, who will be doing 
this job in Text Wrangler. So this solution is too much overhead when I can get 
the job done with two find and replace steps. I appreciate your response, but 
am sorry that you went to so much trouble. I was just wondering if I had 
overlooked a one-step "does not equal" grep function. Apparently not. 

Thanks for your help.

***********************************************************
On Jan 26, 2011, at 8:15 AM , Christopher Stone wrote:

Hey Doug,

Whups.  I was rather short-sighted when I tested...

This is what *I* would do (script below).

It *is* dependent upon the Satimage.osax though (a 3rd party osax:  
http://tinyurl.com/dc3soh

I'm sure one of the Perl guys will offer a nicely terse solution, but this 
works fine on a more complex test file than I used first time around.  You can 
run it from the Applescript Editor or save as a compiled script and run from 
BBEdit's script menu.

It expects your document to be frontmost in BBEdit and will produce output to a 
new window.

--
Best Regards,
Chris


################################################################################################
on regexFindCapture(fndStr, returnStr, dataSource, caseSensitive, regexFlag, 
wholeWord, allOccurrences, stringResult)
 try
   set findResult to find text fndStr ¬
     in dataSource ¬
     case sensitive caseSensitive ¬
     regexp regexFlag ¬
     whole word wholeWord ¬
     using returnStr ¬
     all occurrences allOccurrences ¬
     string result stringResult
   return findResult
 on error # errMsg number errNum
   return false
 end try
end regexFindCapture
################################################################################################
on getBBEditText()
 tell application "BBEdit"
   try
     set bbText to text of front text window
     return bbText
   on error errMsg number errNum
     set sep to "=============================="
     set e to sep & return & "Error: " & errMsg & return & sep & return ¬
       & "Error Number: " & errNum & return & sep
     beep
     display dialog e
   end try
 end tell
end getBBEditText
################################################################################################
on makeOutPutWindow(outPutText)
 tell application "BBEdit"
   try
     make new text window with properties {text:outPutText}
     activate
   on error errMsg number errNum
     set sep to "=============================="
     set e to sep & return & "Error: " & errMsg & return & sep & return ¬
       & "Error Number: " & errNum & return & sep
     beep
     display dialog e
   end try
 end tell
end makeOutPutWindow
################################################################################################

set bbText to getBBEditText()
set extractEmails to regexFindCapture("(<[^@]+@[^@]+?>)", "\\1", bbText, false, 
true, false, true, true)
set extractEmails to sortlist extractEmails comparison 2
set extractEmails to join extractEmails using return
makeOutPutWindow(extractEmails)

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to