* 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.8 KiB
1.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7db8367417b2b2512ba3 | 匹配空白字符 | 1 | 301359 | match-whitespace |
--description--
迄今为止的挑战包括匹配的字母和数字。还可以匹配字母之间的空格。
可以使用\s
搜寻空格,其中s
是小写。此匹配模式不仅匹配空格,还匹配回车符、制表符、换页符和换行符,可以将其视为与[\r\t\f\n\v]
类似。
let whiteSpace = "Whitespace. Whitespace everywhere!"
let spaceRegex = /\s/g;
whiteSpace.match(spaceRegex);
// Returns [" ", " "]
--instructions--
修改正则表达式countWhiteSpace
查找字符串中的多个空白字符。
--hints--
你的正则表达式应该使用全局状态修正符。
assert(countWhiteSpace.global);
正则表达式应该使用元字符 \s
匹配所有的空白。
assert(/\\s/.test(countWhiteSpace.source));
你的正则表达式应该在'Men are from Mars and women are from Venus.'
中匹配到 8 个空白字符。
assert(
'Men are from Mars and women are from Venus.'.match(countWhiteSpace).length ==
8
);
你的正则表达式应该在"Space: the final frontier."
中匹配到 3 个空白字符。
assert('Space: the final frontier.'.match(countWhiteSpace).length == 3);
你的正则表达式在'MindYourPersonalSpace'
中应该匹配不到空白字符。
assert('MindYourPersonalSpace'.match(countWhiteSpace) == null);
--seed--
--seed-contents--
let sample = "Whitespace is important in separating words";
let countWhiteSpace = /change/; // Change this line
let result = sample.match(countWhiteSpace);
--solutions--
let sample = "Whitespace is important in separating words";
let countWhiteSpace = /\s/g;
let result = sample.match(countWhiteSpace);