Revision: 41458
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 18, 2011 09:54 by rumremix
Initial Code
<script type="text/javascript"> var visitorName = "Chuck"; var myOldString = "Hello username! I hope you enjoy your stay username."; var myNewString = myOldString.replace(/username/g, visitorName); document.write("Old string = " + myOldString); document.write("<br />New string = " + myNewString); </script>
Initial URL
http://www.tizag.com/javascriptT/javascript-string-replace.php
Initial Description
Normal replace() function only replaces first instance.
Initial Title
javascript replace all instances in a string
Initial Tags
javascript, replace
Initial Language
JavaScript