> This is probably one of those look ahead|behind things that I still do
> not grasp about regex.
>
> I want to find <td...> tags in a string of HTML that contain an <img...>
> tag.   But I need the entire <td..>...<img...>...</td> string to replace
> it.  But I need to ignore all the other <td...>...</td> blocks that do
> not contain image tags.

Can you elaborate on the context of what you're trying to do here?

Because stuff like this is generally much much simpler with either
XPath or jQuery.



For example, here's how XPath matches any td containing an img:

//td[//img]


And here's how jQuery does it:

$j( 'td:has(img)' )



To do it with RegEx, you want something like this:

(?ims)<td[^>]*>(?:[^/]|/(?!td>))*<img[^>]+>.*?</td>



So yeah, if you really have a specific need to do it with RegEx, you
can probably use that, but I'd generally go for either of the other
two for any tag-based issue like this.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1170
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21

Reply via email to