there are actually two issues with your example.
- Certain characters in Regular Expressions have a special meaning so they'll have to be escaped if you want the character interpreted literally.
Here a fully working example I cooked up for you:
var patt1=/\:\)/g; alert(":):):)".replace(patt1,"*"));
The alert message shows three asterisks!