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

2.0 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7db9367417b2b2512ba5 指定匹配的上限和下限 1 301367 specify-upper-and-lower-number-of-matches

--description--

回想一下,使用加号+查找一个或多个字符,使用星号*查找零个或多个字符。这些都很方便,但有时需要匹配一定范围的匹配模式。

可以使用数量说明符指定匹配模式的上下限。数量说明符与花括号({})一起使用。可以在花括号之间放两个数字,这两个数字代表匹配模式的上限和下限。

例如,要在字符串"ah"中匹配仅出现35次的字母a,正则表达式应为/a{3,5}h/

let A4 = "aaaah";
let A2 = "aah";
let multipleA = /a{3,5}h/;
multipleA.test(A4); // Returns true
multipleA.test(A2); // Returns false

--instructions--

修改正则表达式ohRegex以匹配在"Oh no"中仅出现36次的字母h

--hints--

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

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

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

assert(!ohRegex.test('Ohh no'));

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

assert('Ohhh no'.match(ohRegex)[0].length === 7);

正则表达式应该匹配 "Ohhhh no"

assert('Ohhhh no'.match(ohRegex)[0].length === 8);

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

assert('Ohhhhh no'.match(ohRegex)[0].length === 9);

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

assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);

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

assert(!ohRegex.test('Ohhhhhhh no'));

--seed--

--seed-contents--

let ohStr = "Ohhh no";
let ohRegex = /change/; // Change this line
let result = ohRegex.test(ohStr);

--solutions--

let ohStr = "Ohhh no";
let ohRegex = /Oh{3,6} no/; // Change this line
let result = ohRegex.test(ohStr);