Fix replacing last occurrence of HTML closing tag