Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

2.2 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7db9367417b2b2512ba4 Match Non-Whitespace Characters 1 匹配非空白字符

Description

您学会了使用\s搜索空格,并使用小写s 。您还可以搜索除空格之外的所有内容。使用\S搜索非空格, \S是一个大写的s 。此模式将不匹配空格,回车符,制表符,换页符和换行符。你可以认为它类似于字符类[^ \r\t\f\n\v]
让whiteSpace =“空白。到处都是空白!”
让nonSpaceRegex = / \ S / g;
whiteSpace.matchnonSpaceRegex。长度; //返回32

Instructions

更改正则表达式countNonWhiteSpace以在字符串中查找多个非空白字符。

Tests

tests:
  - text: 你的正则表达式应该使用全局标志。
    testString: assert(countNonWhiteSpace.global);
  - text: 你的正则表达式应该使用速记字符
    testString: assert(/\\S/.test(countNonWhiteSpace.source));
  - text: 你的正则表达式应该在<code>&quot;Men are from Mars and women are from Venus.&quot;</code>找到35个非空格<code>&quot;Men are from Mars and women are from Venus.&quot;</code>
    testString: assert("Men are from Mars and women are from Venus.".match(countNonWhiteSpace).length == 35);
  - text: '你的正则表达式应该在<code>&quot;Space: the final frontier.&quot;</code>找到23个非空格<code>&quot;Space: the final frontier.&quot;</code>'
    testString: 'assert("Space: the final frontier.".match(countNonWhiteSpace).length == 23);'
  - text: 你的正则表达式应该在<code>&quot;MindYourPersonalSpace&quot;</code>找到21个非空格
    testString: assert("MindYourPersonalSpace".match(countNonWhiteSpace).length == 21);

Challenge Seed

let sample = "Whitespace is important in separating words";
let countNonWhiteSpace = /change/; // Change this line
let result = sample.match(countNonWhiteSpace);

Solution

// solution required