Regular Expression {n, m} quantifiers (at least n times, at most m times), regular expression quantifiers
Regular Expression {n, m} quantifiers:
{N, m}
The quantifiers can repeat the previous matching characters for n-m times, at least n times, up to m times.
Syntax structure:
Constructor method:
New RegExp ("x {n, m }")
Method of direct object volume:
/X {n, m }/
Browser support:
Internet Explorer supports this metacharacter.
Firefox supports this metacharacter.
Google Chrome supports this metacharacter.
Instance code:
Instance 1:
Var str = "10000 or"; var reg = new RegExp ("\ d {}", "g"); console. log (str. match (reg ));
The above code can match three or four digits.
Example 2:
Var str = "10000 or"; var reg =/\ d {}/g; console. log (str. match (reg ));
This code serves the same purpose as the above Code. It is just a different definition of regular expressions.
It is recommended that you use this JavaScript Regular Expression online testing tool to view the results when learning.
As shown in the preceding figure, the three numbers only match 1000, and only 3-4 numbers are matched. If there are more than one number, the system will not work.