Computer >> Computer tutorials >  >> Programming >> Javascript

How to find character between brackets in JavaScript RegExp?


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>