On Sun, Mar 21, 2010 at 04:40:12PM -0500, Bill Hernandez wrote:
>
> On Mar 21, 2010, at 10:38 AM, Warren Michelsen wrote:
>
> > Another grep question: How do I find, using grep, the third column within a
> > selected table?
> >
> > I want to delete the third column in its entirety. The opening <td> and
> > closing </td> may be on different lines. So, I need to find and select each
> > instance of <td>SomeTextAcrossMultipleLines</td> provided each such
> > occurrence is the third such occurrence following a <tr>.
>
> Warren,
>
> SEARCH : (<tr[^>]*>)((<td[^>]*>[^<]+</td>[\s]*){2,2})(<td[^>]*>[^<]+</td>)
> REPLACE : \1\2
>
> (<tr[^>]*>)
> ((<td[^>]*>[^<]+</td>[\s]*){2,2})
> (<td[^>]*>[^<]+</td>)
This solution makes a few assumptions that may not be valid. It assumes
that none of the <td> tags will contain nested tags; that none of the <td>
tags will be empty; and that there will be no space between the <tr> and
the first <td>.
Here's an updated version of the regex.
Find
(<tr[^>]*>\s*(?:<td[^>]*>(?:(?!</td>).)*</td>\s*){2})<td[^>]*>(?:(?!</td>).)*</td>
Replace
\1
The key here is the (?:(?!</td>).)*, which will check to see if the next
thing in the string is </td>, and if it's not, it will match one character,
then repeat that, matching one character at a time, until it gets to the
</td>.
Ronald
--
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.
To unsubscribe from this group, send email to
bbedit+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.