* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
2.5 KiB
2.5 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db9367417b2b2512ba5 | Specify Upper and Lower Number of Matches | 1 | 指定上下匹配数 |
Description
+
来查找一个或多个字符,使用星号*
来查找零个或多个字符。这些很方便,但有时你想要匹配一定范围的模式。您可以使用quantity specifiers
模式的下限和上限。数量说明符与大括号( {
和}
)一起使用。您在大括号之间放置了两个数字 - 用于较低和较高的模式数。例如,为了匹配字母"ah"
出现3
到5
次的字母a
,你的正则表达式将是/a{3,5}h/
。 让A4 =“aaaah”;
让A2 =“aah”;
令multipleA = / a {3,5} h /;
multipleA.test(A4); //返回true
multipleA.test(A2); //返回false
Instructions
ohRegex
以匹配单词"Oh no"
中的3
到6
字母h
。 Tests
tests:
- text: 你的正则表达式应该使用大括号。
testString: assert(ohRegex.source.match(/{.*?}/).length > 0);
- text: 你的正则表达式不应该匹配<code>"Ohh no"</code>
testString: assert(!ohRegex.test("Ohh no"));
- text: 你的正则表达式应该匹配<code>"Ohhh no"</code>
testString: assert("Ohhh no".match(ohRegex)[0].length === 7);
- text: 你的正则表达式应该匹配<code>"Ohhhh no"</code>
testString: assert("Ohhhh no".match(ohRegex)[0].length === 8);
- text: 你的正则表达式应该匹配<code>"Ohhhhh no"</code>
testString: assert("Ohhhhh no".match(ohRegex)[0].length === 9);
- text: 你的正则表达式应该匹配<code>"Ohhhhhh no"</code>
testString: assert("Ohhhhhh no".match(ohRegex)[0].length === 10);
- text: 你的正则表达式不应该匹配<code>"Ohhhhhhh no"</code>
testString: assert(!ohRegex.test("Ohhhhhhh no"));
Challenge Seed
let ohStr = "Ohhh no";
let ohRegex = /change/; // Change this line
let result = ohRegex.test(ohStr);
Solution
// solution required