How to find character between brackets in JavaScript RegExp?

HTMLJavascriptProgramming Scripts

To find character between brackets, you need to add the character like the following and use the match() method −

[...]

Example

You can try to run the following code to learn how to find a character between brackets in JavaScript Regular Expression −

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "Welcome! Welcome to the Website!";
         var reg = /[m]/g;
         var match = myStr.match(reg);

         document.write(match);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 06:07:54
Advertisements