907 B
907 B
title, localeTitle
| title | localeTitle |
|---|---|
| Specify Upper and Lower Number of Matches | 指定上下匹配数 |
指定上下匹配数
记住/a{2,4}/返回true ,只要有间两到四个A的一起。对于任何超过四个a的字符串,它将返回true 。
所有这些字符串都将返回true :
let threeAs = "aaa";
let fourAs = "aaaa";
let sevenAs = "aaaaaaa";
let myRegex = /a{2,4}/;
myRegex.test(threeAs) ; // true
myRegex.test(fourAs) ; // true
myRegex.test(sevenAs) ; // true
Spolier Alert!
请记住在Oh{3,6}之后使用\s来包含空格,然后使用no来通过所有测试用例。所有测试用例都是使用大写字母O编写的,但是也可以使用ignore-case传递测试用例: /oh{3,6}\sno/i
解:
let ohStr = "Ohhh no";
let ohRegex = /Oh{3,6}\sno/; // Change this line
let result = ohRegex.test(ohStr);