RegExp . Metacharacter - Javascript RegExp

Javascript examples for RegExp:Metacharacter

Description

The . metacharacter matches a single character, except newline or other line terminators.

The following code shows how to Do a global search for "h.t" in a string:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {/*w w  w.j  a v  a  2s .  com*/
    var str = "not hat hit heavt hooooot hot!";
    var patt1 = /h.t/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials