jQuery Data Type How to - Replace the string value characters








Question

We would like to know how to replace the string value characters.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from ww  w .  ja v  a  2s  .  com-->
    var decoded = "[100, 200, 300, 400, 500]";
    decoded = decoded.replace(/\[/, "");
    decoded = decoded.replace(/\]/, "");
    var s = decoded.split(",");
    document.writeln(s);

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: