2.7 KiB
2.7 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db9367417b2b2512ba6 | Specify Only the Lower Number of Matches | 1 | 仅指定较低的匹配数 |
Description
quantity specifiers
的较低和较高数量的模式。有时您只想指定较低数量的模式而没有上限。要仅指定较少的模式数,请保留第一个数字后跟逗号。例如,要仅匹配字符串"hah"
与出现至少3
次的字母a
,您的正则表达式将是/ha{3,}h/
。 让A4 =“haaaah”;
让A2 =“哈哈”;
设A100 =“h”+“a”.repeat(100)+“h”;
let multipleA = / ha {3,} h /;
multipleA.test(A4); //返回true
multipleA.test(A2); //返回false
multipleA.test(A100); //返回true
Instructions
z
时才更改正则表达式haRegex
以匹配单词"Hazzah"
。 Tests
tests:
- text: 你的正则表达式应该使用大括号。
testString: 'assert(haRegex.source.match(/{.*?}/).length > 0, "Your regex should use curly brackets.");'
- text: 你的正则表达式不应该与<code>"Hazzah"</code>匹配
testString: 'assert(!haRegex.test("Hazzah"), "Your regex should not match <code>"Hazzah"</code>");'
- text: 你的正则表达式不应该与<code>"Hazzzah"</code>匹配
testString: 'assert(!haRegex.test("Hazzzah"), "Your regex should not match <code>"Hazzzah"</code>");'
- text: 你的正则表达应该匹配<code>"Hazzzzah"</code>
testString: 'assert(haRegex.test("Hazzzzah"), "Your regex should match <code>"Hazzzzah"</code>");'
- text: 你的正则表达应该匹配<code>"Hazzzzzah"</code>
testString: 'assert(haRegex.test("Hazzzzzah"), "Your regex should match <code>"Hazzzzzah"</code>");'
- text: 你的正则表达应该匹配<code>"Hazzzzzzah"</code>
testString: 'assert(haRegex.test("Hazzzzzzah"), "Your regex should match <code>"Hazzzzzzah"</code>");'
- text: 你的正则表达式应该匹配<code>"Hazzah"</code>和30个<code>z</code> 。
testString: 'assert(haRegex.test("Ha" + "z".repeat(30) + "ah"), "Your regex should match <code>"Hazzah"</code> with 30 <code>z</code>\"s in it.");'
Challenge Seed
let haStr = "Hazzzzah";
let haRegex = /change/; // Change this line
let result = haRegex.test(haStr);
Solution
// solution required