I have this:

    <div class="to_remove">
    <div class="widget widget-list">
    <div class="panel panel-default">
    <div class="panel-heading bold">Menu</div>
    <div class="panel-body">
      content
    </div>
    </div>
    </div>
  </div>

I need preg_replace to edit like this:

        <div class="widget widget-list">
        <div class="panel panel-default">
        <div class="panel-heading bold">Menu</div>
        <div class="panel-body">
          content
        </div>
        </div>
    </div> 

I need to remove <div class="to_remove"></div> but the content between tags must be stay.

In your example you open 5 – five divs (you have five <div>) and you close 4- four divs (you have </div>), what exactly is it ? . If it were all nice and clean its quite simple:

Html:

    <div class="to_remove">
        <div class="widget widget-list">
            <div class="panel panel-default">
                <div class="panel-heading bold">Menu</div>
                    <div class="panel-body">
                    content
                    </div>
                </div>
            </div>
        </div>
    </div>  

JavaScript:

        var $children = $(".to_remove").children();
        $children.insertBefore(".to_remove");
        $(".to_remove").remove();

I don't think that I should also point the inconsistency in css class names (e.g. - in widget-list but _ in to_remove also it is a panel why should be “panel panel-default” and not just “panel default” ?)

Anyone else ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.