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

3.2 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7db7367417b2b2512b9c Find One or More Criminals in a Hunt 1 在狩猎中找到一个或多个罪犯

Description

是时候暂停和测试你的新正则表达式写作技巧了。一群罪犯逃出监狱逃跑但你不知道有多少人。但是你知道他们和其他人在一起时会保持紧密联系。你有责任立刻找到所有的罪犯。下面是一个查看如何执行此操作的示例regex /z+/在连续出现一次或多次时匹配字母z 。它会在以下所有字符串中找到匹配项:
“Z”
“ZZZZZZ”
“ABCzzzz”
“zzzzABC”
“abczzzzzzzzzzzzzzzzzzzzzabc”
但它没有在以下字符串中找到匹配项,因为没有字母z字符:
“”
“ABC”
“ABCABC”

Instructions

写一个greedy正则表达式,在一群其他人中找到一个或多个罪犯。罪犯由大写字母C

Tests

tests:
  - text: 您正则表达式应该匹配<code>one</code>犯罪(“ <code>C</code>中”), <code>&quot;C&quot;</code>
    testString: assert('C'.match(reCriminals) && 'C'.match(reCriminals)[0] == 'C');
  - text: 您正则表达式应该匹配<code>two</code>罪犯(“ <code>CC</code>中”) <code>&quot;CC&quot;</code>
    testString: assert('CC'.match(reCriminals) && 'CC'.match(reCriminals)[0] == 'CC');
  - text: 你的正则表达式应匹配<code>&quot;P1P5P4CCCP2P6P3&quot;</code>中的<code>three</code>罪犯(“ <code>CCC</code> ”)
    testString: assert('P1P5P4CCCP2P6P3'.match(reCriminals) && 'P1P5P4CCCP2P6P3'.match(reCriminals)[0] == 'CCC');
  - text: 你的正则表达式应匹配<code>&quot;P6P2P7P4P5CCCCCP3P1&quot;</code>中的<code>five</code>罪犯(“ <code>CCCCC</code> ”)
    testString: assert('P6P2P7P4P5CCCCCP3P1'.match(reCriminals) && 'P6P2P7P4P5CCCCCP3P1'.match(reCriminals)[0] == 'CCCCC');
  - text: 你的正则表达式不应该匹配<code>&quot;&quot;</code>中的任何罪犯
    testString: assert(!reCriminals.test(''));
  - text: 你的正则表达式不应该匹配<code>&quot;P1P2P3&quot;</code>中的任何罪犯
    testString: assert(!reCriminals.test('P1P2P3'));
  - text: 您正则表达式应该与<code>fifty</code>的罪犯(“ <code>CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</code>中”) <code>&quot;P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3&quot;</code> 。
    testString: assert('P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals) && 'P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals)[0] == "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC");

Challenge Seed

// example crowd gathering
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';

let reCriminals = /./; // Change this line

let matchedCriminals = crowd.match(reCriminals);
console.log(matchedCriminals);

Solution

// solution required