Match any string containing a sequence of N p's

HTMLJavascriptProgramming Scripts

To match any string containing a sequence of N p’s with JavaScript RegExp, use the p{N} Quantifier.

Example

You can try to run the following code to match any string containing a sequence of N p’s:

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>

   <body>
      <script>
         var myStr = "Welcome 1, 100, 10000, 1000";
         var reg = /\d{3}/g;
         var match = myStr.match(reg);
         
         document.write(match);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 08:03:17
Advertisements