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
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5d712346c441eddfaeb5bdef 匹配所有数字 1 18181 match-all-numbers

--description--

已经了解了常见字符串匹配模式的元字符,如字母数字。另一个常见的匹配模式是只寻找数字。

查找数字字符的缩写是\d,注意是小写的d。这等同于元字符[0-9],它查找 0 到 9 之间任意数字的单个字符。

--instructions--

使用缩写\d来计算电影标题中有多少个数字。书面数字("six" 而不是 6不计算在内。

--hints--

你的正则表达式应该使用缩写来匹配数字字符。

assert(/\\d/.test(numRegex.source));

你的正则表达式应该使用全局状态修正符。

assert(numRegex.global);

你的正则表达式应该在'9'中匹配到 1 个数字。

assert('9'.match(numRegex).length == 1);

你的正则表达式应该在'Catch 22'中匹配到 2 个数字。

assert('Catch 22'.match(numRegex).length == 2);

你的正则表达式应该在'101 Dalmatians'中匹配到 3 个数字。

assert('101 Dalmatians'.match(numRegex).length == 3);

你的正则表达式在'One, Two, Three'中应该匹配不到数字。

assert('One, Two, Three'.match(numRegex) == null);

你的正则表达式应该在'21 Jump Street'中匹配到 2 个数字。

assert('21 Jump Street'.match(numRegex).length == 2);

你的正则表达式应该在"2001: A Space Odyssey"中匹配到 4 个数字。

assert('2001: A Space Odyssey'.match(numRegex).length == 4);

--seed--

--seed-contents--

let movieName = "2001: A Space Odyssey";
let numRegex = /change/; // Change this line
let result = movieName.match(numRegex).length;

--solutions--

let movieName = "2001: A Space Odyssey";
let numRegex = /\d/g; // Change this line
let result = movieName.match(numRegex).length;