@cybmole - yeah I get caught out every now and then too - particularly trailing line feeds from the "invisible" character that code view uses to terminate lines. Just have to pay close attention to your selections
Also as said above you will be less error prone if you replace the whole tag including the angle brackets - that way an accidental space before or after the tag will have no impact.