JavaScript \xdd Metacharacter | Find Character using HexaDecimal Number

The JavaScript \xdd metacharacter is used when we need match a character using its hexadecimal number (in the form xdd), while working with JavaScript regular expression. For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>

   <p id="xyz"></p>

   <script>
      let myString = "JavaScript is Fun.";
      let pattern = /\x75/;
      document.getElementById("xyz").innerHTML = myString.search(pattern);
   </script>
   
</body>
</html>
Output

Since the hexadecimal value 75 refers to u. And the index of u in the string is 15. Therefore the program has produced 15 as output.

Note: The search() is used to search a substring (value) in a string using regular expression.

JavaScript Online Test


« Previous Tutorial Next Tutorial »