Not sure if you need such a loop if you're just replacing characters as you can do a partial match?