I have the following problem. I want to insert in a table only these lists which are in a table cell. These which are not in a table let's keep it that way
Here is my code:
$replaceList = '$1$2<table class="listTbl"><tr><td>$3</td></tr></table>$4$5';
$html = preg_replace('/(<td>){1}(.*?)(<ul>[\s\S]*?<\/ul>)(.*?)(<\/td>){1}/smi', $replaceList, $html);
If there is following:
To become:<table>
<tr>
<td>Test</td>
</tr>
<tr>
<td>
Text here
<ul>
<li>Test1</li>
<li>Test2</li>
</ul>
Text
</td>
</tr>
Thanks!<table>
<tr>
<td>Test</td>
</tr>
<tr>
<td>
Text here
<table class="listTbl"><tr><td>
<ul>
<li>Test1</li>
<li>Test2</li>
</ul>
</td></tr></table>
Text
</td>
</tr>