Search notes:
JavaScript: String.replace
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>JavaScript RegExp replace()</title>
<script type="text/javascript">
var out;
function replaceFooWithBar(str) {
var str_replaced = str.replace('Foo', 'Bar');
out.innerHTML += "Turned <code>" + str + "</code> into <code>" + str_replaced + "</code><br>";
}
function main() {
out = document.getElementById('out');
replaceFooWithBar("A Foo and a Baz");
replaceFooWithBar("a foo and a baz");
replaceFooWithBar("Foo foo Foo foo");
}
</script>
</head>
<body onload="main();">
<div id="out">
</div>
<p><code>replace()</code> can also be used with <a href='../RegExp/replace.html'>Regular Expressions</a>.
</body>
</html>