0

I have this code

<div class="kakaa">
    <div class="hihi">
        <div>dfsfsdf</div>
        <div class="haha">
            <div id="kaka">ohfoehwf</div>
        </div>
    </div>
    <div class="main">
        <div>lorem</div>
    </div>
</div>

Now, i want to remove div has class hihi, how to do it become

<div class="kakaa">
    <div class="main">
        <div>lorem</div>
    </div>
</div>
Phi Tống
  • 11
  • 3
  • You definitely [shouldn't be using regex to parse HTML](http://stackoverflow.com/q/1732348/540162) (unless you're 1001% sure you know what you're doing). – Nightfirecat Nov 18 '11 at 07:31

1 Answers1

0

You didn't specify if you're doing this on server-side or client-side. If client-side, no regex is necessary. Use jQuery:

$('.hihi').remove();

Here's a reference: http://api.jquery.com/remove/

If you're doing it server-side, don't use regex (you'll never be able to cover all the possibilities in an HTML tag with regex). Instead use a HTML DOM parser. Here's a very simple one: http://simplehtmldom.sourceforge.net/

Jonathan M
  • 17,145
  • 9
  • 58
  • 91
  • I use simplehtmldom parse another site, but in the simplehtmldom can get html or content each block, not support remove tag same as above – Phi Tống Nov 18 '11 at 08:17