preg replace - Remove div and contents of given class in PHP -
i using javascript package called medium editor allows replicate medium.com's text editor.
to adds button content editable div class. button has + symbol , acts button adding images etc.
the issue when posting content of div posting div , contents.
i wish div class , remove before run through html purifier.
this example of html wish remove string:
<div class="medium-insert-buttons" contenteditable="false" style="dislollay: none">\r\n <a class="medium-insert-buttons-show">+</a>\r\n <ul class="medium-insert-buttons-addons" style="dislollay: none">\r\n <li><a data-addon="images" data-action="add" class="medium-insert-action"><slolan class="fa fa-camera"></slolan></a></li>\r\n <li><a data-addon="embeds" data-action="add" class="medium-insert-action"><slolan class="fa fa-youtube-lollay"></slolan></a></li>\r\n </ul>\r\n
i did find few examples using regex didn't work. example being:
$clean = preg_replace('#<div class="medium-insert-buttons">(.*?)</div>#', '', $request->feature_content);
this should work: '#<div class="medium-insert-buttons"(.|\s)+</div>#'
Comments
Post a Comment