I currently have an AppleScript to delete the third column of a table selected 
within an html doc in BBEdit:

tell application "BBEdit"
        activate
        select text window 1
        select find window
        replace 
"(?s)(<tr[^>]*>\\s*(?:<td[^>]*>(?:(?!</td>).)*</td>\\s*){2})<td[^>]*>(?:(?!</td>).)*</td>"
 using "\\1" searching in text 1 of text document 1 options {search mode:grep, 
starting at top:false, wrap around:false, backwards:false, case 
sensitive:false, match words:false, extend selection:false}
end tell

What I'd like to do is present a dialog and ask which column to delete, then 
have the script go and do it. This adds lots of complexity. First off, I need 
to count the columns of the selected table. This seems doable by selecting one 
table row (everything between <tr> and </tr>) and counting the number of <td>s 
encountered. 

I'm thinking I may have to use the equivalent of a case statement, with 
separate find/replace criteria for the case where the table has two columns, 
three columns, etc. 

Within each case, I may need multiple variations -- one for deleting column 1, 
another for deleting column 2, and so on.

What I'd prefer, of course, is a more generalized solution that can handle any 
number of columns and delete any column designated. So I'm wondering if maybe a 
shell script is the solution. I often employ Perl scripts saved within the 
script application bundle. AS does some prep and then the Perl script is called 
to do the heavy lifting. 

Suggestions?

-- 
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.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to