JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html>
<body>
<script>
function replaceValue(source, find, replacement)
{
var s, i, arr = "\\ ^ $ * + ? { } , . ( ) : = ! | [ ] -".split(" ");
for (i=0; i<arr.length; i++){
re = new RegExp("\\"+arr[i],"igm");
find = find.replace(re, "\\"+arr[i]);
}
re = new RegExp(find,"igm");
s = source.replace(re, replacement);
alert(s);
}
</script>
<form>
<input type="text" id="t1" value="$0.00"/>
<input type=button id="btn" onclick="replaceValue('Value= $val$','$val$',document.getElementById('t1').value);" value="Replace $val$" />
</form>
</body>
</html>