Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.9 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7db9367417b2b2512ba6 只指定匹配的下限 1 301366 specify-only-the-lower-number-of-matches

--description--

可以使用带有花括号的数量说明符来指定匹配模式的上下限。但有时候只想指定匹配模式的下限而不需要指定上限。

为此,在第一个数字后面跟一个逗号即可。

例如,要匹配至少出现3次字母a的字符串"hah",正则表达式应该是/ha{3,}h/

let A4 = "haaaah";
let A2 = "haah";
let A100 = "h" + "a".repeat(100) + "h";
let multipleA = /ha{3,}h/;
multipleA.test(A4); // Returns true
multipleA.test(A2); // Returns false
multipleA.test(A100); // Returns true

--instructions--

修改正则表达式haRegex,匹配包含四个或更多字母z的单词"Hazzah"

--hints--

你的正则表达式应该使用花括号。

assert(haRegex.source.match(/{.*?}/).length > 0);

你的正则表达式不应该匹配'Hazzah'

assert(!haRegex.test('Hazzah'));

你的正则表达式不应该匹配'Hazzzah'

assert(!haRegex.test('Hazzzah'));

正则表达式应该匹配 "Hazzzzah"

assert('Hazzzzah'.match(haRegex)[0].length === 8);

你的正则表达式应该匹配'Hazzzzah'

assert('Hazzzzzah'.match(haRegex)[0].length === 9);

正则表达式应该匹配 "Hazzzzzzah"

assert('Hazzzzzzah'.match(haRegex)[0].length === 10);

正则表达式应该匹配 "Hazzah" with 30 z's in it.

assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);

--seed--

--seed-contents--

let haStr = "Hazzzzah";
let haRegex = /change/; // Change this line
let result = haRegex.test(haStr);

--solutions--

let haStr = "Hazzzzah";
let haRegex = /Haz{4,}ah/; // Change this line
let result = haRegex.test(haStr);