Use non-greedy quantifiers.
Instead of <td[^>]*>
Use <td.*?>

You can also cluster characters by using the positional assertion (?:...)
-in your case, (?:(</td>))

BBEdit's Help topic "Searching with GREP" has an in-depth discussion or
GREP. I've found that reading the help with a file open and finding things
using the different patterns discussed is most salutary...

But since you're in a hurry,

Use: (<td.*?>)(.+)(?:</td>)

.*? will find everything up to the closing angle bracket of the opening tag

(?:</td>) will find the literal string </td> -instead of capturing, just use
</td>, not \3

Dennis Cox


On 10/31/08 9:31 AM, "Govinda" <[EMAIL PROTECTED]> wrote:

> 
> Hi all
> 
> I am writing to ask for a little help understanding grep searches.  I
> have been using them in a light-weight fashion for years, but I need
> to deepen my abilities here to save more time while coding...
> 
> specifically, now, I don't understand how to find "not some word".
> Say I want to find all the <td>'s (including their contents and
> closing tags) in a selection (or just one after another), so that I
> can change the contents of the <td> to be wrapped in <b> tags or some
> deeper-level cgi tags, etc, (whatever)....  and so I write a grep like
> this:
> (<td[^>]*>)([^<]+)(<\/td>)
> (replace will be something like:
> \1\[cgiTag\]\2\[\/cgiTag\]\3
> 
> Now here's where I need to learn more:  The above works whenever the
> inner contents of the <td> do not already have any "<" chars.  But
> what if they do?  My character class #2 now effectively says:
> "anything except a '<' char".  But what I really want is for character
> class #2 to effectively say: "anything except the literal string '</
> td>'".  I know how to find literal strings and also how to find NOT
> certain characters (*individually*), but I don't know how to find NOT
> an exact sequence of chars.   I have been through the docs and fiddled
> with efforts as deep as my brain could wrap around it all in between
> real-world work/deadlines, so now I am asking in friendly English for
> friendly English help.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
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 specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to "[EMAIL PROTECTED]" 
rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to