It wouldn't strip anything except what you put in there. Like I said, the IF isn't really necessary. You would specifically put all of the codes into the $replacex like I was showing.
Of course, regex may be a simpler way to do something like this if there is a specific pattern to follow.