<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button to do a global search for "Schools" NOT at the beginning or end of a word in a string.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
var str = "Visit W3Schools";
var patt1 = /\BSchool/g;
var result = str.match(patt1);
document.getElementById("demo").innerHTML=result;
}
</script>

</body>
</html>