Home >Operation and Maintenance >Safety >How to match specific quantity in javascript

How to match specific quantity in javascript

王林
王林forward
2023-05-17 15:19:061254browse

Explanation

1. The number of curly bracket specifiers can be used to specify the upper and lower limits of the matching pattern. But sometimes only a specific number of matches is needed.

2. To specify a certain number of matching patterns, just place a number between the curly brackets.

Example

要求
修改正则表达式timRegex,以匹配仅有四个字母 m 的单词 Timber。
let timStr = "Timmmmber";
let timRegex = /change/; // 修改这一行
let result = timRegex.test(timStr);
 
参考
let timStr = "Timmmmber";
let timRegex = /tim{4}ber/i; // 修改这一行
let result = timRegex.test(timStr);

The above is the detailed content of How to match specific quantity in javascript. For more information, please follow other related articles on the PHP Chinese website!

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