hello I have the following code :
$content = '<div class="style1" id="divelement" align="center">';
and here is my code :
preg_replace('~<div\s*.*?(?:\s*class\s*=\s*"(.*?)"\s*|\s*id\s*=\s*"(.*?)"\s*)?>~i','<div class="$1" id="$2">', $content);
now what I'm trying is to replace the whole elements but keep class and id only .