in reply to Match last instance of pattern

If you run perl 5.10.0 or later, you can use this regex: s/.*\K<\/TABLE>/REPLACE/

If you're not that fortunate, you could use captures: s/(.*)<\/TABLE>/${1}REPLACE/