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.7 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7db6367417b2b2512b99 匹配出现一次或多次的字符 1 301350 match-characters-that-occur-one-or-more-times

--description--

有时,需要匹配出现一次或者连续多次的的字符(或字符组)。这意味着它至少出现一次,并且可能重复出现。

可以使用+符号来检查情况是否如此。记住,字符或匹配模式必须一个接一个地连续出现。

例如,/a+/g会在"abc"中匹配到一个匹配项,并且返回["a"]。因为+的存在,它也会在"aabc"中匹配到一个匹配项,然后返回["aa"]

如果它是检查字符串"abab",它将匹配到两个匹配项并且返回["a", "a"],因为a字符不连续,在它们之间有一个b字符。最后,因为在字符串"bcd"中没有"a",因此找不到匹配项。

--instructions--

想要在字符串"Mississippi"中匹配到出现一次或多次的字母s的匹配项。编写一个使用+符号的正则表达式。

--hints--

你的正则表达式myRegex应该使用+符号来匹配一个或多个s字符。

assert(/\+/.test(myRegex.source));

你的正则表达式myRegex应该匹配两项。

assert(result.length == 2);

结果变量应该是一个包含两个'ss'匹配项的数组。

assert(result[0] == 'ss' && result[1] == 'ss');

--seed--

--seed-contents--

let difficultSpelling = "Mississippi";
let myRegex = /change/; // Change this line
let result = difficultSpelling.match(myRegex);

--solutions--

let difficultSpelling = "Mississippi";
let myRegex = /s+/g; // Change this line
let result = difficultSpelling.match(myRegex);