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

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7db6367417b2b2512b99 Match Characters that Occur One or More Times 1 匹配出现一次或多次的字符

Description

有时,您需要匹配连续出现一次或多次的字符(或字符组)。这意味着它至少发生一次,并且可以重复。您可以使用+字符来检查是否是这种情况。请记住,角色或模式必须连续出现。也就是说,角色必须一个接一个地重复。例如, /a+/g会在"abc"找到一个匹配并返回["a"] 。由于+ ,它也会在"aabc"找到一个匹配并返回["aa"] 。如果它是检查字符串"abab" ,它会找到两个匹配并返回["a", "a"]因为a字符不在一行 - 它们之间有一个b 。最后,由于字符串"bcd"没有"a" "bcd" ,因此找不到匹配项。

Instructions

您希望在"Mississippi"字母s出现一次或多次时找到匹配项。写一个使用+符号的正则表达式。

Tests

tests:
  - text: 你的正则表达式<code>myRegex</code>应该使用<code>+</code>符号来匹配一个或多个<code>s</code>字符。
    testString: assert(/\+/.test(myRegex.source));
  - text: 你的正则表达式<code>myRegex</code>应该匹配2个项目。
    testString: assert(result.length == 2);
  - text: <code>result</code>变量应该是一个包含两个匹配<code>&quot;ss&quot;</code>的数组
    testString: assert(result[0] == 'ss' && result[1] == 'ss');

Challenge Seed

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

Solution

// solution required