<html>
<body>
<p>Click the button to set "blue", "house" and "car" to upper-case, in the paragraph below:</p>
<p id="demo">Mr Blue has a blue house and a blue car.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var res = str.replace(/blue|house|car/gi, function (x) {
return x.toUpperCase();
});
document.getElementById("demo").innerHTML = res;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_replace4 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:01:37 GMT -->
</html>