<script>
var str = "I am a foo, I want a bar.";
document.write(str.replace("a","#"));
</script>
Result :
This replace the first occurrence , the first a only,
<script>
var str = "I am a foo, I want a bar.";
document.write(str.replace(/a/g,"#"));
</script>
Resulr:
No comments :
Post a Comment