* 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>
1.7 KiB
1.7 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7db5367417b2b2512b96 | 匹配字母表中的字母 | 1 | 301354 | match-letters-of-the-alphabet |
--description--
了解了如何使用字符集
来指定要匹配的一组字符串,但是当需要匹配大量字符(例如,字母表中的每个字母)时,有一种写法可以让实现这个功能变得简短。
在字符集
中,可以使用连字符
(-
)来定义要匹配的字符范围。
例如,要匹配小写字母a
到e
,你可以使用[a-e]
。
let catStr = "cat";
let batStr = "bat";
let matStr = "mat";
let bgRegex = /[a-e]at/;
catStr.match(bgRegex); // Returns ["cat"]
batStr.match(bgRegex); // Returns ["bat"]
matStr.match(bgRegex); // Returns null
--instructions--
匹配字符串quoteSample
中的所有字母。
注意:
一定要同时匹配大小写字母。****
--hints--
你的正则表达式alphabetRegex
应该匹配 35 项。
assert(result.length == 35);
你的正则表达式alphabetRegex
应该使用全局标志。
assert(alphabetRegex.flags.match(/g/).length == 1);
你的正则表达式alphabetRegex
应该使用忽略大小写标志。
assert(alphabetRegex.flags.match(/i/).length == 1);
--seed--
--seed-contents--
let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /change/; // Change this line
let result = alphabetRegex; // Change this line
--solutions--
let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /[a-z]/gi; // Change this line
let result = quoteSample.match(alphabetRegex); // Change this line