Hi, I have a script that import content into my website,and I want to replace some data.I can replace div classes,but not the ID's inside the classes.Example: <div class="Content" id="i_need to remove that" data-shortlistID="I have to rename" data-natID="remove agian"> So,to remove the div class i use: $html = preg_replace('#<div[^>]*class="Content"[^>]*>.*?</div>#is', '', $html); To rename the div class i use: $html = preg_replace('#(<div[^>]*class=")Content("[^>]*>.*?</div>)#is', '$1New-Content$2', $html); But how can remove/rename the ID's inside <div class="Content" ? I'm not coder,so please excuse me poor language Thanks in advance Krasi
$html = preg_replace('#class="Content" id="(.*?)"#','',$html); // replace with nothing or insert class="Content" between the empty '' quotes $html = preg_replace('#data-natID="(.*?)"#','',$html); // replace with nothing $somethingelse = "something"; // new data-shortlistID $html = preg_replace('#data-shortlistID="(.*?)"#','data-shortlistID="'.$somethingelse.'"',$html); // renames data-shortlistID with $somethingelse PHP: