Hi everyone, I can't seem to get preg_replace to remove the contents and tags of span tags in a document. Here is my replace code. The document source ($text) is retrieved through curl. $text8 = preg_replace('/class=".*?"/ims',"", $text); $text7 = preg_replace('/style=".*?"/ims',"", $text8); $text6 = preg_replace('/id=".*?"/ims',"", $text7); $str = preg_replace("/<span.*?<\/span>/ims","", $text6); echo $str; PHP: Does anyone know what I'm doing wrong? Thanks!
Escape special characters , I always use % instead of backslashes in case there are some in the string .. , as % is rarely used
Remove the contents including the span tags ? $str = preg_replace('#<span[^>]*>(.*)</span>#isU','', $str); PHP: