-1

Possible Duplicate:
RegEx match open tags except XHTML self-contained tags

How can I remove whole div's of an HTML source code ? To remove it I would replace with an empty string but I'm unable to get a pattern which matches. The class name is always given.

For example I need to remove the whole div with class name zzz

<div class="zzz"> 
    <b>some html</b>
    (other div's could be inside) 
<div>

Hope someone can help me

Community
  • 1
  • 1
peipst9lker
  • 605
  • 1
  • 5
  • 17

3 Answers3

1

Using jQuery, you just need to do $("div.zzz").remove().

sp00m
  • 47,968
  • 31
  • 142
  • 252
0

For this kind of things it's better to parse the DOM and manipulate parsed object.

Because divs may be nested and you can't control the end of block.

Obviously if you are acting in client-side you can use jquery's

$(div.xxxx).remove()
kappa
  • 1,559
  • 8
  • 19
-1

Easier than regex is to use jQuery

$('.zzz').remove()

joe
  • 777
  • 5
  • 10
  • this if you are operating client-side, what if you have to do it on server, after getting data from 3rd party service? – kappa Apr 24 '12 at 07:09