Escaped "$" in replacements.
Character escaping on regular expression.
Use Array.split|join instead of String.replace because it fails in IE7 if replacement controls are in use.