Home >Web Front-end >HTML Tutorial >Match any string containing N occurrences of p

Match any string containing N occurrences of p

王林
王林forward
2023-09-23 23:53:021245browse

Match any string containing N occurrences of p

To match any string containing N p sequences with a JavaScript RegExp, use the p{N} quantifier.

Example

You can try running the following code to match any string containing N p sequences -

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

The above is the detailed content of Match any string containing N occurrences of p. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete