On Thu, Oct 29, 2009 at 05:30, BB Design <bradbans...@gmail.com> wrote: > I'm using BB Edit grep to select <a></a> links like this: > > (\<a.*\<\/a>) > > So I can paste the match using: \1 > > However, I basically want to delete everything else in the document > except these links, so that all I am left with is the links. Possible > to modify my code to accomplish this? Thanks! >
I'd use an Applescript to do this: remove all Return characters -- gets everything on one line replace <a with \r<a -- puts a Return before a link replace /a> with /a>\r -- puts a Return after a link Process lines containing <a and put them in a new document Done. Applescript experts would undoubtedly improve on this, but I just tried it on the source of a random webpage and it appeared to do the trick in a second or so: -- This script pulls out all links -- from an HTML source document tell application "BBEdit" activate tell text 1 of text window 1 -- remove Returns replace "\\r" using "" options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} -- isolate links replace "<a" using "\\r<a" options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} replace "/a>" using "/a>\\r" options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} -- put out lines with links process lines containing matching string "<a" output options {copying to new document:true} end tell end tell -- end script Cheers, Miraz -- Miraz Jordan WordPress ebooks for non-techies: http://knowit.co.nz/bookstore Dogs. Fun. Outdoors. : http://runspotrun.info iPod, iPhone, Mac Tips: http://mactips.info --~--~---------~--~----~------------~-------~--~----~ 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 bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com 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 "supp...@barebones.com" rather than posting to the group. -~----------~----~----~----~------~----~------~--~---