* 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.2 KiB
1.2 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7dbb367417b2b2512bac | 删除开头和结尾的空白 | 1 | 301362 | remove-whitespace-from-start-and-end |
--description--
有时字符串周围存在的空白字符并不是必需的。字符串的典型处理是删除字符串开头和结尾处的空格。
--instructions--
编写一个正则表达式并使用适当的字符串方法删除字符串开头和结尾的空格。
注意:
.trim()
方法在这里也可以实现同样的效果,但是你需要使用正则表达式来完成此项挑战。
--hints--
结果
应该等于'Hello, World!'
。
assert(result == 'Hello, World!');
你不应该使用.trim()
方法。
assert(!code.match(/\.trim\(.*?\)/));
结果
变量不应该设置为等于字符串。
assert(!code.match(/result\s*=\s*".*?"/));
--seed--
--seed-contents--
let hello = " Hello, World! ";
let wsRegex = /change/; // Change this line
let result = hello; // Change this line
--solutions--
let hello = " Hello, World! ";
let wsRegex = /^(\s+)(.+[^\s])(\s+)$/;
let result = hello.replace(wsRegex, '$2');