<!DOCTYPE html>
<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 myFunction(x){return x.toUpperCase();});
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>