Do a global search for at least one word character: - Javascript RegExp

Javascript examples for RegExp:Bracket

Description

Do a global search for at least one word character:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from ww w  .  j ava 2s .  co m
    var str = "Hellooo World! Hello The following code shows how to !";
    var patt1 = /\w+/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials