i would like to ask, how to replace char "(" and ")" with ""
it is because i can only replace either ( or ) with "" instead of both
how to achieve the goal??
that is
original: (abc, def)
modified: abc, def
thanks
my code:
<html>
<body>
<script type="text/javascript">
var str="(abc, def)";
document.write(str.replace("(",""));
</script>
</body>
</html>
Use a regexp, and the g for global replacements:
var str="(abc, def)";
document.write(str.replace(/[()]/g,''));
For reference: http://javascriptkit.com/jsref/regexp.shtml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With