in reply to Match last instance of pattern

No need to involve the regex engine.

perl -0777 -pe "substr $_, rindex($_,'</TABLE>'), 8, 'REPLACE'" x.html