Since you have a reply with a code that works, I'll just point out that your original code has a typo in it.

The $replace line uses $replce (notice the missing a)