/<table[\s]+cellspacing="0"[\s]+class="cj(?:.*?)"[\s]+id="(?:.*?)">(?:.*?)value="(.*?)"(?:.*?)<td[\s]+class="dep">(.*?)<\/td>(?:.*)(?:<td[\s]+class="arr">(.*?)<\/td>)+(?:.*?)<\/table>/
This is my current regex string, used in PHP with preg_match_all(). I replaced (?:.*?) with (?:.*) so that instead of getting the first <td> with class="dep", it gets the last one. Now, this works perfectly, unless there is more than one table, in which case it gets the last <td> with class="dep" from the entire parsed string. Can anyone help me understand what I did wrong?
Also, I know I should have used XML parsing, but it seemed way too complicated for me 😛
Edit: Also, what I actually want is the <td> that is before the first </table> tag.
Ended up fixing it by getting the table with one regex, then parsing its contents with another.