in reply to greedy/nongreedy regex replacement
$string =~ s/<tr(?:(?!<tr>).)+?NOTWANTED.+?<\/tr>//gsm; [download]