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.5 KiB
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7dba367417b2b2512ba8 检查全部或无 1 301338 check-for-all-or-none

--description--

有时,想要搜寻的匹配模式可能有不确定是否存在的部分。尽管如此,还是想检查它们。

为此,可以使用问号?指定可能存在的元素。这将检查前面的零个或一个元素。可以将此符号视为前面的元素是可选的。

例如,美式英语和英式英语略有不同,可以使用问号来匹配两种拼写。

let american = "color";
let british = "colour";
let rainbowRegex= /colou?r/;
rainbowRegex.test(american); // Returns true
rainbowRegex.test(british); // Returns true

--instructions--

修改正则表达式favRegex以匹配美式英语favorite和英式英语favourite的单词版本。

--hints--

你的正则表达式应该使用可选符号?

assert(favRegex.source.match(/\?/).length > 0);

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

assert(favRegex.test('favorite'));

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

assert(favRegex.test('favourite'));

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

assert(!favRegex.test('fav'));

--seed--

--seed-contents--

let favWord = "favorite";
let favRegex = /change/; // Change this line
let result = favRegex.test(favWord);

--solutions--

let favWord = "favorite";
let favRegex = /favou?r/;
let result = favRegex.test(favWord);