Code: Select all
<tr>
<td> ... </td>
<td> ... </td>
<td>SUBSTRING I HAVE TO MATCH HERE</td>
<td> ... </td>
<td> ... </td>
</tr>
To ensure SUBSTRING occurs inside a row, you need to use this:
Code: Select all
<tr>((?!</tr>).)+?SUBSTRING.+?</tr>
To ensure that SUBSTRING does not occur inside the row, we can simply put SUBSTRING into that negative lookahead we already have:
Code: Select all
<tr>((?!SUBSTRING).)+?</tr>
+? Match 1 or more times, not greedily
?? Match 0 or 1 time, not greedily