RegExp \uxxxx Metacharacter - Javascript RegExp

Javascript examples for RegExp:Metacharacter

Description

The \uxxxx character matches the Unicode character specified by a hexadecimal number xxxx.

If no match is found, it returns null.

The following code shows how to Do a global search for the hexadecimal number 0057 (W) in a string:

The marked text below shows where the expression gets a match:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {//  www  .j  a va2  s .  c  o  m
    var str = "Visit java2s.com. Hello World!";
    var patt1 = /\u0057/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials