On Jan 29, 2007, at 12:03 PM, Warren Michelsen wrote:
Is it possible, as an alternate strategy, to specify that between <td and </tr> there may be multiple lines? Treating the entire line as one long line seems to complicate things. Is there no way to specify any character at all, including newlines? Worked just fine. The only drawback is that my Eudora turned various characters of the pattern into sad smileys. Copied and pasted just fine though. Just out of curiosity, suppose I wanted to eliminate column N instead of the last one. Is grep up to the task? (I'm certainly not.) Such things as this would be nice to script: Select a table, choose the "Delete Table Column" script from the Scripts menu, respond with the number of the column to delete and execute. If that can be done, then it ought to be possible to add a column as well, at column position N, etc.


If it can be assumed that you already know the layout of the code for the table with a reasonable certainty, it is possible to write a Grep pattern such as you hint at above.

For instance, if one could assume that your table is laid out as follows:
<table summary="some summary info">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
      <th>Header 3</th>
    </tr>
  </thead>
    <tr>
      <td>Row 1 Column 1</td>
      <td>Row 1 Column 2</td>
      <td>Row 1 Column 3</td>
    </tr>
    <tr>
      <td>Row 2 Column 1</td>
      <td>Row 2 Column 2</td>
      <td>Row 2 Column 3</td>
    </tr>
    <tr>
      <td>Row 3 Column 1</td>
      <td>Row 3 Column 2</td>
      <td>Row 3 Column 3</td>
    </tr>
    <tr>
      <td>Row 4 Column 1</td>
      <td>Row 4 Column 2</td>
      <td>Row 4 Column 3</td>
    </tr>
    <tr>
      <td>Row 5 Column 1</td>
      <td>Row 5 Column 2</td>
      <td>Row 5 Column 3</td>
    </tr>
    <tr>
      <td>Row 6 Column 1</td>
      <td>Row 6 Column 2</td>
      <td>Row 6 Column 3</td>
    </tr>
    <tr>
      <td>Row 7 Column 1</td>
      <td>Row 7 Column 2</td>
      <td>Row 7 Column 3</td>
    </tr>
    <tr>
      <td>Row 8 Column 1</td>
      <td>Row 8 Column 2</td>
      <td>Row 8 Column 3</td>
    </tr>
  <tbody>
  </tbody>
</table>

Then if you did a GREP find/replace in BBEdit for:
([ \t]+<tr>[\r\n]+)([ \t]+<td>.*</td>[\r\n]+)([ \t]+<td>.*</td>[\r\n] +)([ \t]+<td>.*</td>[\r\n]+)([ \t]+</tr>[\r\n]+)

Replacing with:
\1\2\4\5

You would remove Column 2 - the third of the five () delimited patterns in the Find expression. If you instead wanted to remove the first column, your replacement string would be:
\1\3\4\5

And so forth.


--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to