Substitute in Javascript Using replace Method
To substitute in Javascript, use the replace() method:
hu = "LENDEN";
hu = hu.replace(/e/ig, "o");
Which Prints:
LoNDoN
-We created a variable and named it hu because we felt like it.
-We said to replace the any letter "e"s you find with "o"s. The
i means case-INsensitive. The
g means change ALL "e"s, not just the first one.
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
hu = "LENDEN";
hu = hu.replace(/e/ig, "o");
document.write(hu);
-->
</script>