How to match specific quantity in javascript

王林
Release: 2023-05-17 15:19:06
forward
1183 people have browsed it

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);
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!