Using the replace() method of the String object : replace « String « JavaScript Tutorial






<html>
<head>
<title>Using the replace() method of the String object</title>
<script type="text/javascript" language="javascript">
<!-- //
var originalString = "A ab abc abcd";
var replacedString = "a";
var replacementString = "z";

var newString = originalString.replace(replacedString, replacementString);

document.write("<h3>" + newString + "</h3");
// -->
</script>
</head>
<body>

</body>
</html>








6.23.replace
6.23.1.String.replace()
6.23.2.Using the replace() method of the String object