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

1.7 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7db3367417b2b2512b8e Using the Test Method 1 使用测试方法

Description

正则表达式用于编程语言以匹配字符串的一部分。您可以创建模式来帮助您进行匹配。如果你想在字符串"The dog chased the cat"找到单词"the" ,你可以使用以下正则表达式: /the/ 。请注意,正则表达式中不需要引号。 JavaScript有多种方法可以使用正则表达式。测试正则表达式的一种方法是使用.test()方法。 .test()方法接受正则表达式,将其应用于字符串(放在括号内),如果模式发现或不存在,则返回truefalse
让testStr =“freeCodeCamp”;
让testRegex = / Code /;
testRegex.testtestStr;
//返回true

Instructions

使用.test()方法在字符串myString上应用正则表达式myRegex

Tests

tests:
  - text: 你应该使用<code>.test()</code>来测试正则表达式。
    testString: assert(code.match(/myRegex.test\(\s*myString\s*\)/));
  - text: 您的结果应该返回<code>true</code> 。
    testString: assert(result === true);

Challenge Seed

let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex; // Change this line

Solution

// solution required