Please be more descriptive when you say, "it doesn't work".
Anyway, have a look at W3Schools here:
JavaScript replace() Method
There are a few things you need to look into:
- Is there more than one instance? If so, a Global search will need to be performed
- Should it be case sensitive? Case insensitive? There's a different way to handle these situations
The link I provided should help you.