I’m trying to replace two tags
</th>
</tr>
with
</th>
</tr>
</thead>
I think the line break between the tags is preventing the replacement below from working:
$str = preg_replace('/(<\/th>)+(\/tr)/i', '</th></tr></thead>', $str);
Any suggestions please?
This is the regex solution:
Note that the
\s*matches any whitespace and you were missing<and>around the/tr.As pointed out above, an HTML/DOM parser might be better suited to what you want to do.