<tr>
<td width="300" bgcolor="#cccccc" style="text-align: right;">
<strong> Sometext<br />
</strong>
</td>
<td width="125" bgcolor="#009900" style="text-align: center;">
<strong><span style="color: rgb(255, 255, 255);">
<span style="font-size: larger;">Pricetoreplace</span>
</span>
</strong>
</td>
</tr>
I need to remove whole <tr>....</tr> row, if it contain the "Pricetoreplace" text in it.
I've tried next:
$content = preg_replace('~(<tr.*[\'"]Pricetoreplace[\'"].*tr>)~', '', $content);
But it didnt work.
tr>so your regex is not going to do what you expect (you use greedy quantifiers.*instead of lazy quantifiers.*?). Second, your.doesn't match new line characters, you should use[\s\S]instead or turn on thesflag to match newline characters with the.character. Again, though, you shouldn't even be using regex for this.