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

How to find a character, not between the brackets in JavaScript RegExp?


To find a character, not between brackets, you need to add the character like the following −

[^...]

Example

You can try to run the following code to learn how to find a character, not between the brackets −

<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>