How can replace values as array by replace in javascript.
I want done replace numbers (for example) together. how is it?
1 -replace whit-> 11
2 -replace whit-> 22
DEMO: http://jsfiddle.net/ygxfy/
<script type="text/javascript">
var array = {"1":"11", "2":"22"}
var str="13332";
document.write(str.replace(array));
</script>
You have to create a pattern, using a RegEx, and then pass it to the
.replacemethod.