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
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
6a7a7e6d7d
commit
b3213fc892
@ -18,13 +18,13 @@ localeTitle: 检查全部或无
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用可选的符号, <code>?</code> 。
|
||||
testString: 'assert(favRegex.source.match(/\?/).length > 0, "Your regex should use the optional symbol, <code>?</code>.");'
|
||||
testString: assert(favRegex.source.match(/\?/).length > 0);
|
||||
- text: 你的正则表达式应该匹配<code>"favorite"</code>
|
||||
testString: 'assert(favRegex.test("favorite"), "Your regex should match <code>"favorite"</code>");'
|
||||
testString: assert(favRegex.test("favorite"));
|
||||
- text: 你的正则表达式应该匹配<code>"favourite"</code>
|
||||
testString: 'assert(favRegex.test("favourite"), "Your regex should match <code>"favourite"</code>");'
|
||||
testString: assert(favRegex.test("favourite"));
|
||||
- text: 你的正则表达式不应该匹配<code>"fav"</code>
|
||||
testString: 'assert(!favRegex.test("fav"), "Your regex should not match <code>"fav"</code>");'
|
||||
testString: assert(!favRegex.test("fav"));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 提取匹配
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>result</code>应该有单词<code>coding</code>
|
||||
testString: 'assert(result.join() === "coding", "The <code>result</code> should have the word <code>coding</code>");'
|
||||
testString: assert(result.join() === "coding");
|
||||
- text: 你的regex <code>codingRegex</code>应该搜索<code>coding</code>
|
||||
testString: 'assert(codingRegex.source === "coding", "Your regex <code>codingRegex</code> should search for <code>coding</code>");'
|
||||
testString: assert(codingRegex.source === "coding");
|
||||
- text: 您应该使用<code>.match()</code>方法。
|
||||
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the <code>.match()</code> method.");'
|
||||
testString: assert(code.match(/\.match\(.*\)/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 找到比第一场比赛更多的东西
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>starRegex</code>应该使用全局标志<code>g</code>
|
||||
testString: 'assert(starRegex.flags.match(/g/).length == 1, "Your regex <code>starRegex</code> should use the global flag <code>g</code>");'
|
||||
testString: assert(starRegex.flags.match(/g/).length == 1);
|
||||
- text: 你的正则表达式<code>starRegex</code>应该使用不区分大小写的标志<code>i</code>
|
||||
testString: 'assert(starRegex.flags.match(/i/).length == 1, "Your regex <code>starRegex</code> should use the case insensitive flag <code>i</code>");'
|
||||
testString: assert(starRegex.flags.match(/i/).length == 1);
|
||||
- text: 您的匹配应匹配<code>"Twinkle"</code>一词的出现次数
|
||||
testString: 'assert(result.sort().join() == twinkleStar.match(/twinkle/gi).sort().join(), "Your match should match both occurrences of the word <code>"Twinkle"</code>");'
|
||||
testString: assert(result.sort().join() == twinkleStar.match(/twinkle/gi).sort().join());
|
||||
- text: 您的匹配<code>result</code>应该包含两个元素。
|
||||
testString: 'assert(result.length == 2, "Your match <code>result</code> should have two elements in it.");'
|
||||
testString: assert(result.length == 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,19 +18,19 @@ localeTitle: 在狩猎中找到一个或多个罪犯
|
||||
```yml
|
||||
tests:
|
||||
- text: 您正则表达式应该匹配<code>one</code>犯罪(“ <code>C</code>中”), <code>"C"</code>
|
||||
testString: 'assert("C".match(reCriminals) && "C".match(reCriminals)[0] == "C", "Your regex should match <code>one</code> criminal ("<code>C</code>") in <code>"C"</code>");'
|
||||
testString: assert('C'.match(reCriminals) && 'C'.match(reCriminals)[0] == 'C');
|
||||
- text: 您正则表达式应该匹配<code>two</code>罪犯(“ <code>CC</code>中”) <code>"CC"</code>
|
||||
testString: 'assert("CC".match(reCriminals) && "CC".match(reCriminals)[0] == "CC", "Your regex should match <code>two</code> criminals ("<code>CC</code>") in <code>"CC"</code>");'
|
||||
testString: assert('CC'.match(reCriminals) && 'CC'.match(reCriminals)[0] == 'CC');
|
||||
- text: 你的正则表达式应匹配<code>"P1P5P4CCCP2P6P3"</code>中的<code>three</code>罪犯(“ <code>CCC</code> ”)
|
||||
testString: 'assert("P1P5P4CCCP2P6P3".match(reCriminals) && "P1P5P4CCCP2P6P3".match(reCriminals)[0] == "CCC", "Your regex should match <code>three</code> criminals ("<code>CCC</code>") in <code>"P1P5P4CCCP2P6P3"</code>");'
|
||||
testString: assert('P1P5P4CCCP2P6P3'.match(reCriminals) && 'P1P5P4CCCP2P6P3'.match(reCriminals)[0] == 'CCC');
|
||||
- text: 你的正则表达式应匹配<code>"P6P2P7P4P5CCCCCP3P1"</code>中的<code>five</code>罪犯(“ <code>CCCCC</code> ”)
|
||||
testString: 'assert("P6P2P7P4P5CCCCCP3P1".match(reCriminals) && "P6P2P7P4P5CCCCCP3P1".match(reCriminals)[0] == "CCCCC", "Your regex should match <code>five</code> criminals ("<code>CCCCC</code>") in <code>"P6P2P7P4P5CCCCCP3P1"</code>");'
|
||||
testString: assert('P6P2P7P4P5CCCCCP3P1'.match(reCriminals) && 'P6P2P7P4P5CCCCCP3P1'.match(reCriminals)[0] == 'CCCCC');
|
||||
- text: 你的正则表达式不应该匹配<code>""</code>中的任何罪犯
|
||||
testString: 'assert(!reCriminals.test(""), "Your regex should not match any criminals in <code>""</code>");'
|
||||
testString: assert(!reCriminals.test(''));
|
||||
- text: 你的正则表达式不应该匹配<code>"P1P2P3"</code>中的任何罪犯
|
||||
testString: 'assert(!reCriminals.test("P1P2P3"), "Your regex should not match any criminals in <code>"P1P2P3"</code>");'
|
||||
testString: assert(!reCriminals.test('P1P2P3'));
|
||||
- text: 您正则表达式应该与<code>fifty</code>的罪犯(“ <code>CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</code>中”) <code>"P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3"</code> 。
|
||||
testString: 'assert("P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3".match(reCriminals) && "P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3".match(reCriminals)[0] == "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", "Your regex should match <code>fifty</code> criminals ("<code>CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</code>") in <code>"P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3"</code>.");'
|
||||
testString: assert('P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals) && 'P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals)[0] == "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,25 +18,25 @@ localeTitle: 匹配时忽略大小写
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该与<code>freeCodeCamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("freeCodeCamp"), "Your regex should match <code>freeCodeCamp</code>");'
|
||||
testString: assert(fccRegex.test('freeCodeCamp'));
|
||||
- text: 你的正则表达式应该与<code>FreeCodeCamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FreeCodeCamp"), "Your regex should match <code>FreeCodeCamp</code>");'
|
||||
testString: assert(fccRegex.test('FreeCodeCamp'));
|
||||
- text: 你的正则表达式应该与<code>FreecodeCamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FreecodeCamp"), "Your regex should match <code>FreecodeCamp</code>");'
|
||||
testString: assert(fccRegex.test('FreecodeCamp'));
|
||||
- text: 你的正则表达式应该与<code>FreeCodecamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FreeCodecamp"), "Your regex should match <code>FreeCodecamp</code>");'
|
||||
testString: assert(fccRegex.test('FreeCodecamp'));
|
||||
- text: 你的正则表达式不应该与<code>Free Code Camp</code>不匹配
|
||||
testString: 'assert(!fccRegex.test("Free Code Camp"), "Your regex should not match <code>Free Code Camp</code>");'
|
||||
testString: assert(!fccRegex.test('Free Code Camp'));
|
||||
- text: 你的正则表达式应该与<code>FreeCOdeCamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FreeCOdeCamp"), "Your regex should match <code>FreeCOdeCamp</code>");'
|
||||
testString: assert(fccRegex.test('FreeCOdeCamp'));
|
||||
- text: 你的正则表达式不应该与<code>FCC</code>匹配
|
||||
testString: 'assert(!fccRegex.test("FCC"), "Your regex should not match <code>FCC</code>");'
|
||||
testString: assert(!fccRegex.test('FCC'));
|
||||
- text: 你的正则表达式应该与<code>FrEeCoDeCamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FrEeCoDeCamp"), "Your regex should match <code>FrEeCoDeCamp</code>");'
|
||||
testString: assert(fccRegex.test('FrEeCoDeCamp'));
|
||||
- text: 你的正则表达式应该与<code>FrEeCodECamp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FrEeCodECamp"), "Your regex should match <code>FrEeCodECamp</code>");'
|
||||
testString: assert(fccRegex.test('FrEeCodECamp'));
|
||||
- text: 你的正则表达式应该与<code>FReeCodeCAmp</code>匹配
|
||||
testString: 'assert(fccRegex.test("FReeCodeCAmp"), "Your regex should match <code>FReeCodeCAmp</code>");'
|
||||
testString: assert(fccRegex.test('FReeCodeCAmp'));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,19 +18,19 @@ localeTitle: 匹配具有不同可能性的文字字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>petRegex</code>应该为字符串<code>"John has a pet dog."</code>返回<code>true</code> <code>"John has a pet dog."</code>
|
||||
testString: 'assert(petRegex.test("John has a pet dog."), "Your regex <code>petRegex</code> should return <code>true</code> for the string <code>"John has a pet dog."</code>");'
|
||||
testString: assert(petRegex.test('John has a pet dog.'));
|
||||
- text: 你的正则表达式<code>petRegex</code>应该为字符串<code>"Emma has a pet rock."</code>返回<code>false</code> <code>"Emma has a pet rock."</code>
|
||||
testString: 'assert(!petRegex.test("Emma has a pet rock."), "Your regex <code>petRegex</code> should return <code>false</code> for the string <code>"Emma has a pet rock."</code>");'
|
||||
testString: assert(!petRegex.test('Emma has a pet rock.'));
|
||||
- text: 你的正则表达式<code>petRegex</code>应该为字符串<code>"Emma has a pet bird."</code>返回<code>true</code> <code>"Emma has a pet bird."</code>
|
||||
testString: 'assert(petRegex.test("Emma has a pet bird."), "Your regex <code>petRegex</code> should return <code>true</code> for the string <code>"Emma has a pet bird."</code>");'
|
||||
testString: assert(petRegex.test('Emma has a pet bird.'));
|
||||
- text: 你的正则表达式<code>petRegex</code>应该返回<code>true</code>为字符串<code>"Liz has a pet cat."</code>
|
||||
testString: 'assert(petRegex.test("Liz has a pet cat."), "Your regex <code>petRegex</code> should return <code>true</code> for the string <code>"Liz has a pet cat."</code>");'
|
||||
testString: assert(petRegex.test('Liz has a pet cat.'));
|
||||
- text: 你的正则表达式<code>petRegex</code>应该返回<code>false</code>为<code>"Kara has a pet dolphin."</code>的字符串<code>"Kara has a pet dolphin."</code>
|
||||
testString: 'assert(!petRegex.test("Kara has a pet dolphin."), "Your regex <code>petRegex</code> should return <code>false</code> for the string <code>"Kara has a pet dolphin."</code>");'
|
||||
testString: assert(!petRegex.test('Kara has a pet dolphin.'));
|
||||
- text: 你的正则表达式<code>petRegex</code>应该返回<code>true</code>为字符串<code>"Alice has a pet fish."</code>
|
||||
testString: 'assert(petRegex.test("Alice has a pet fish."), "Your regex <code>petRegex</code> should return <code>true</code> for the string <code>"Alice has a pet fish."</code>");'
|
||||
testString: assert(petRegex.test('Alice has a pet fish.'));
|
||||
- text: 你的正则表达式<code>petRegex</code>应该返回<code>false</code>为字符串<code>"Jimmy has a pet computer."</code>
|
||||
testString: 'assert(!petRegex.test("Jimmy has a pet computer."), "Your regex <code>petRegex</code> should return <code>false</code> for the string <code>"Jimmy has a pet computer."</code>");'
|
||||
testString: assert(!petRegex.test('Jimmy has a pet computer.'));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 匹配所有字母和数字
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用全局标志。
|
||||
testString: 'assert(alphabetRegexV2.global, "Your regex should use the global flag.");'
|
||||
testString: assert(alphabetRegexV2.global);
|
||||
- text: 你的正则表达式应该使用速记字符
|
||||
testString: 'assert(/\\w/.test(alphabetRegexV2.source), "Your regex should use the shorthand character <code>\w</code> to match all characters which are alphanumeric.");'
|
||||
testString: assert(/\\w/.test(alphabetRegexV2.source));
|
||||
- text: 你的正则表达式应该在<code>"The five boxing wizards jump quickly."</code>找到31个字母数字字符<code>"The five boxing wizards jump quickly."</code>
|
||||
testString: 'assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31, "Your regex should find 31 alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>");'
|
||||
testString: assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31);
|
||||
- text: 你的正则表达式应该在<code>"Pack my box with five dozen liquor jugs."</code>找到32个字母数字字符<code>"Pack my box with five dozen liquor jugs."</code>
|
||||
testString: 'assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32, "Your regex should find 32 alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>");'
|
||||
testString: assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32);
|
||||
- text: 你的正则表达式应该在<code>"How vexingly quick daft zebras jump!"</code>找到30个字母数字字符<code>"How vexingly quick daft zebras jump!"</code>
|
||||
testString: 'assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30, "Your regex should find 30 alphanumeric characters in <code>"How vexingly quick daft zebras jump!"</code>");'
|
||||
testString: assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30);
|
||||
- text: 你的正则表达式应该在<code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>找到36个字母数字字符<code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>
|
||||
testString: 'assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(alphabetRegexV2).length === 36, "Your regex should find 36 alphanumeric characters in <code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>");'
|
||||
testString: assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(alphabetRegexV2).length === 36);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 匹配所有非数字
|
||||
```yml
|
||||
tests:
|
||||
- text: 您的正则表达式应使用快捷方式字符来匹配非数字字符
|
||||
testString: 'assert(/\\D/.test(noNumRegex.source), "Your regex should use the shortcut character to match non-digit characters");'
|
||||
testString: assert(/\\D/.test(noNumRegex.source));
|
||||
- text: 你的正则表达式应该使用全局标志。
|
||||
testString: 'assert(noNumRegex.global, "Your regex should use the global flag.");'
|
||||
testString: assert(noNumRegex.global);
|
||||
- text: 你的正则表达式应该在<code>"9"</code>找不到非数字。
|
||||
testString: 'assert("9".match(noNumRegex) == null, "Your regex should find no non-digits in <code>"9"</code>.");'
|
||||
testString: assert("9".match(noNumRegex) == null);
|
||||
- text: 你的正则表达式应该在<code>"Catch 22"</code>找到6个非数字。
|
||||
testString: 'assert("Catch 22".match(noNumRegex).length == 6, "Your regex should find 6 non-digits in <code>"Catch 22"</code>.");'
|
||||
testString: assert("Catch 22".match(noNumRegex).length == 6);
|
||||
- text: 你的正则表达式应该在<code>"101 Dalmatians"</code>找到11个非数字。
|
||||
testString: 'assert("101 Dalmatians".match(noNumRegex).length == 11, "Your regex should find 11 non-digits in <code>"101 Dalmatians"</code>.");'
|
||||
testString: assert("101 Dalmatians".match(noNumRegex).length == 11);
|
||||
- text: '你的正则表达式应该在<code>"One, Two, Three"</code>找到15个非数字。'
|
||||
testString: 'assert("One, Two, Three".match(noNumRegex).length == 15, "Your regex should find 15 non-digits in <code>"One, Two, Three"</code>.");'
|
||||
testString: assert("One, Two, Three".match(noNumRegex).length == 15);
|
||||
- text: 你的正则表达式应该在<code>"21 Jump Street"</code>找到12个非数字。
|
||||
testString: 'assert("21 Jump Street".match(noNumRegex).length == 12, "Your regex should find 12 non-digits in <code>"21 Jump Street"</code>.");'
|
||||
testString: assert("21 Jump Street".match(noNumRegex).length == 12);
|
||||
- text: '你的正则表达式应该在<code>"2001: A Space Odyssey"</code>找到17个非数字。'
|
||||
testString: 'assert("2001: A Space Odyssey".match(noNumRegex).length == 17, "Your regex should find 17 non-digits in <code>"2001: A Space Odyssey"</code>.");'
|
||||
testString: 'assert("2001: A Space Odyssey".match(noNumRegex).length == 17);'
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 匹配所有号码
|
||||
```yml
|
||||
tests:
|
||||
- text: 您的正则表达式应使用快捷方式字符来匹配数字字符
|
||||
testString: 'assert(/\\d/.test(numRegex.source), "Your regex should use the shortcut character to match digit characters");'
|
||||
testString: assert(/\\d/.test(numRegex.source));
|
||||
- text: 你的正则表达式应该使用全局标志。
|
||||
testString: 'assert(numRegex.global, "Your regex should use the global flag.");'
|
||||
testString: assert(numRegex.global);
|
||||
- text: 你的正则表达式应该在<code>"9"</code>找到1位数。
|
||||
testString: 'assert("9".match(numRegex).length == 1, "Your regex should find 1 digit in <code>"9"</code>.");'
|
||||
testString: assert("9".match(numRegex).length == 1);
|
||||
- text: 你的正则表达式应该在<code>"Catch 22"</code>找到2位数字。
|
||||
testString: 'assert("Catch 22".match(numRegex).length == 2, "Your regex should find 2 digits in <code>"Catch 22"</code>.");'
|
||||
testString: assert("Catch 22".match(numRegex).length == 2);
|
||||
- text: 你的正则表达式应该在<code>"101 Dalmatians"</code>找到3位数字。
|
||||
testString: 'assert("101 Dalmatians".match(numRegex).length == 3, "Your regex should find 3 digits in <code>"101 Dalmatians"</code>.");'
|
||||
testString: assert("101 Dalmatians".match(numRegex).length == 3);
|
||||
- text: '你的正则表达式应该在<code>"One, Two, Three"</code>找不到数字。'
|
||||
testString: 'assert("One, Two, Three".match(numRegex) == null, "Your regex should find no digits in <code>"One, Two, Three"</code>.");'
|
||||
testString: assert("One, Two, Three".match(numRegex) == null);
|
||||
- text: 您的正则表达式应该在<code>"21 Jump Street"</code>找到2位数字。
|
||||
testString: 'assert("21 Jump Street".match(numRegex).length == 2, "Your regex should find 2 digits in <code>"21 Jump Street"</code>.");'
|
||||
testString: assert("21 Jump Street".match(numRegex).length == 2);
|
||||
- text: '你的正则表达式应该在<code>"2001: A Space Odyssey"</code>找到4位数字。'
|
||||
testString: 'assert("2001: A Space Odyssey".match(numRegex).length == 4, "Your regex should find 4 digits in <code>"2001: A Space Odyssey"</code>.");'
|
||||
testString: 'assert("2001: A Space Odyssey".match(numRegex).length == 4);'
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,25 +18,25 @@ localeTitle: 匹配通配符期间的任何内容
|
||||
```yml
|
||||
tests:
|
||||
- text: 您应该使用<code>.test()</code>方法。
|
||||
testString: 'assert(code.match(/\.test\(.*\)/), "You should use the <code>.test()</code> method.");'
|
||||
testString: assert(code.match(/\.test\(.*\)/));
|
||||
- text: 您应该在正则表达式<code>unRegex</code>使用通配符
|
||||
testString: 'assert(/\./.test(unRegex.source), "You should use the wildcard character in your regex <code>unRegex</code>");'
|
||||
testString: assert(/\./.test(unRegex.source));
|
||||
- text: 你的正则表达式<code>unRegex</code>应该匹配<code>"run"</code> <code>"Let us go on a run."</code> <code>"run"</code>中的<code>"run"</code> <code>"Let us go on a run."</code>
|
||||
testString: 'assert(unRegex.test("Let us go on a run."), "Your regex <code>unRegex</code> should match <code>"run"</code> in <code>"Let us go on a run."</code>");'
|
||||
testString: assert(unRegex.test("Let us go on a run."));
|
||||
- text: 你的正则表达式<code>unRegex</code>应该与<code>"sun"</code> <code>"The sun is out today."</code> <code>"sun"</code>中的<code>"sun"</code>匹配<code>"The sun is out today."</code>
|
||||
testString: 'assert(unRegex.test("The sun is out today."), "Your regex <code>unRegex</code> should match <code>"sun"</code> in <code>"The sun is out today."</code>");'
|
||||
testString: assert(unRegex.test("The sun is out today."));
|
||||
- text: 你的正则表达式<code>unRegex</code>应该与<code>"fun"</code> <code>"Coding is a lot of fun."</code> <code>"fun"</code>中的<code>"fun"</code>匹配<code>"Coding is a lot of fun."</code>
|
||||
testString: 'assert(unRegex.test("Coding is a lot of fun."), "Your regex <code>unRegex</code> should match <code>"fun"</code> in <code>"Coding is a lot of fun."</code>");'
|
||||
testString: assert(unRegex.test("Coding is a lot of fun."));
|
||||
- text: 你的正则表达式<code>unRegex</code>应该匹配<code>"pun"</code> <code>"Seven days without a pun makes one weak."</code> <code>"pun"</code> <code>"Seven days without a pun makes one weak."</code>
|
||||
testString: 'assert(unRegex.test("Seven days without a pun makes one weak."), "Your regex <code>unRegex</code> should match <code>"pun"</code> in <code>"Seven days without a pun makes one weak."</code>");'
|
||||
testString: assert(unRegex.test("Seven days without a pun makes one weak."));
|
||||
- text: 你的正则表达式<code>unRegex</code>应该与<code>"nun"</code> <code>"One takes a vow to be a nun."</code> <code>"nun"</code>中的<code>"nun"</code>匹配<code>"One takes a vow to be a nun."</code>
|
||||
testString: 'assert(unRegex.test("One takes a vow to be a nun."), "Your regex <code>unRegex</code> should match <code>"nun"</code> in <code>"One takes a vow to be a nun."</code>");'
|
||||
testString: assert(unRegex.test("One takes a vow to be a nun."));
|
||||
- text: 你的正则表达式<code>unRegex</code>应该匹配<code>"bun"</code> <code>"She got fired from the hot dog stand for putting her hair in a bun."</code> <code>"bun"</code>中的<code>"bun"</code> <code>"She got fired from the hot dog stand for putting her hair in a bun."</code>
|
||||
testString: 'assert(unRegex.test("She got fired from the hot dog stand for putting her hair in a bun."), "Your regex <code>unRegex</code> should match <code>"bun"</code> in <code>"She got fired from the hot dog stand for putting her hair in a bun."</code>");'
|
||||
testString: assert(unRegex.test("She got fired from the hot dog stand for putting her hair in a bun."));
|
||||
- text: 您的正则表达式<code>unRegex</code>不应与<code>"There is a bug in my code."</code>匹配<code>"There is a bug in my code."</code>
|
||||
testString: 'assert(!unRegex.test("There is a bug in my code."), "Your regex <code>unRegex</code> should not match <code>"There is a bug in my code."</code>");'
|
||||
testString: assert(!unRegex.test("There is a bug in my code."));
|
||||
- text: 您的正则表达式<code>unRegex</code>不应该匹配<code>"Catch me if you can."</code>
|
||||
testString: 'assert(!unRegex.test("Can me if you can."), "Your regex <code>unRegex</code> should not match <code>"Catch me if you can."</code>");'
|
||||
testString: assert(!unRegex.test("Can me if you can."));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 匹配开始字符串模式
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该用大写字母搜索<code>"Cal"</code> 。
|
||||
testString: 'assert(calRegex.source == "^Cal", "Your regex should search for <code>"Cal"</code> with a capital letter.");'
|
||||
testString: assert(calRegex.source == "^Cal");
|
||||
- text: 你的正则表达式不应该使用任何标志。
|
||||
testString: 'assert(calRegex.flags == "", "Your regex should not use any flags.");'
|
||||
testString: assert(calRegex.flags == "");
|
||||
- text: 你的正则表达式应该匹配字符串开头的<code>"Cal"</code> 。
|
||||
testString: 'assert(calRegex.test("Cal and Ricky both like racing."), "Your regex should match <code>"Cal"</code> at the beginning of the string.");'
|
||||
testString: assert(calRegex.test("Cal and Ricky both like racing."));
|
||||
- text: 您的正则表达式不应与字符串中间的<code>"Cal"</code>匹配。
|
||||
testString: 'assert(!calRegex.test("Ricky and Cal both like racing."), "Your regex should not match <code>"Cal"</code> in the middle of a string.");'
|
||||
testString: assert(!calRegex.test("Ricky and Cal both like racing."));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 匹配出现一次或多次的字符
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>myRegex</code>应该使用<code>+</code>符号来匹配一个或多个<code>s</code>字符。
|
||||
testString: 'assert(/\+/.test(myRegex.source), "Your regex <code>myRegex</code> should use the <code>+</code> sign to match one or more <code>s</code> characters.");'
|
||||
testString: assert(/\+/.test(myRegex.source));
|
||||
- text: 你的正则表达式<code>myRegex</code>应该匹配2个项目。
|
||||
testString: 'assert(result.length == 2, "Your regex <code>myRegex</code> should match 2 items.");'
|
||||
testString: assert(result.length == 2);
|
||||
- text: <code>result</code>变量应该是一个包含两个匹配<code>"ss"</code>的数组
|
||||
testString: 'assert(result[0] == "ss" && result[1] == "ss", "The <code>result</code> variable should be an array with two matches of <code>"ss"</code>");'
|
||||
testString: assert(result[0] == 'ss' && result[1] == 'ss');
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 匹配出现零次或多次的字符
|
||||
```yml
|
||||
tests:
|
||||
- text: 您正则表达式<code>chewieRegex</code>应该使用<code>*</code>字符匹配零个或多个<code>a</code>字符。
|
||||
testString: 'assert(/\*/.test(chewieRegex.source), "Your regex <code>chewieRegex</code> should use the <code>*</code> character to match zero or more <code>a</code> characters.");'
|
||||
testString: assert(/\*/.test(chewieRegex.source));
|
||||
- text: 你的正则表达式<code>chewieRegex</code>应匹配16个字符。
|
||||
testString: 'assert(result[0].length === 16, "Your regex <code>chewieRegex</code> should match 16 characters.");'
|
||||
testString: assert(result[0].length === 16);
|
||||
- text: 你的正则表达式应该匹配<code>"Aaaaaaaaaaaaaaaa"</code> 。
|
||||
testString: 'assert(result[0] === "Aaaaaaaaaaaaaaaa", "Your regex should match <code>"Aaaaaaaaaaaaaaaa"</code>.");'
|
||||
testString: assert(result[0] === "Aaaaaaaaaaaaaaaa");
|
||||
- text: '你的正则表达式不应该与<code>"He made a fair move. Screaming about it can't help you."</code>中的任何角色相匹配<code>"He made a fair move. Screaming about it can't help you."</code>'
|
||||
testString: 'assert(!"He made a fair move. Screaming about it can\"t help you.".match(chewieRegex), "Your regex should not match any characters in <code>"He made a fair move. Screaming about it can't help you."</code>");'
|
||||
testString: assert(!"He made a fair move. Screaming about it can\"t help you.".match(chewieRegex));
|
||||
- text: '你的正则表达式不应该与<code>"Let him have it. It's not wise to upset a Wookiee."</code>中的任何角色相匹配<code>"Let him have it. It's not wise to upset a Wookiee."</code>'
|
||||
testString: 'assert(!"Let him have it. It\"s not wise to upset a Wookiee.".match(chewieRegex), "Your regex should not match any characters in <code>"Let him have it. It's not wise to upset a Wookiee."</code>");'
|
||||
testString: assert(!"Let him have it. It\"s not wise to upset a Wookiee.".match(chewieRegex));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 匹配结束字符串模式
|
||||
```yml
|
||||
tests:
|
||||
- text: 您应该在正则表达式中使用美元符号<code>$</code> anchor搜索<code>"caboose"</code> 。
|
||||
testString: 'assert(lastRegex.source == "caboose$", "You should search for <code>"caboose"</code> with the dollar sign <code>$</code> anchor in your regex.");'
|
||||
testString: assert(lastRegex.source == "caboose$");
|
||||
- text: 你的正则表达式不应该使用任何标志。
|
||||
testString: 'assert(lastRegex.flags == "", "Your regex should not use any flags.");'
|
||||
testString: assert(lastRegex.flags == "");
|
||||
- text: 您应该在字符串末尾匹配<code>"caboose"</code> <code>"The last car on a train is the caboose"</code>
|
||||
testString: 'assert(lastRegex.test("The last car on a train is the caboose"), "You should match <code>"caboose"</code> at the end of the string <code>"The last car on a train is the caboose"</code>");'
|
||||
testString: assert(lastRegex.test("The last car on a train is the caboose"));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 匹配一切,但字母和数字
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用全局标志。
|
||||
testString: 'assert(nonAlphabetRegex.global, "Your regex should use the global flag.");'
|
||||
testString: assert(nonAlphabetRegex.global);
|
||||
- text: 你的正则表达式应该在<code>"The five boxing wizards jump quickly."</code>找到6个非字母数字字符<code>"The five boxing wizards jump quickly."</code> 。
|
||||
testString: 'assert("The five boxing wizards jump quickly.".match(nonAlphabetRegex).length == 6, "Your regex should find 6 non-alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>.");'
|
||||
testString: assert("The five boxing wizards jump quickly.".match(nonAlphabetRegex).length == 6);
|
||||
- text: 你的正则表达式应该使用速记字符。
|
||||
testString: 'assert(/\\W/.test(nonAlphabetRegex.source), "Your regex should use the shorthand character to match characters which are non-alphanumeric.");'
|
||||
testString: assert(/\\W/.test(nonAlphabetRegex.source));
|
||||
- text: 你的正则表达式应该在<code>"Pack my box with five dozen liquor jugs."</code>找到8个非字母数字字符<code>"Pack my box with five dozen liquor jugs."</code>
|
||||
testString: 'assert("Pack my box with five dozen liquor jugs.".match(nonAlphabetRegex).length == 8, "Your regex should find 8 non-alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>");'
|
||||
testString: assert("Pack my box with five dozen liquor jugs.".match(nonAlphabetRegex).length == 8);
|
||||
- text: 你的正则表达式应该在<code>"How vexingly quick daft zebras jump!"</code>找到6个非字母数字字符<code>"How vexingly quick daft zebras jump!"</code>
|
||||
testString: 'assert("How vexingly quick daft zebras jump!".match(nonAlphabetRegex).length == 6, "Your regex should find 6 non-alphanumeric characters in <code>"How vexingly quick daft zebras jump!"</code>");'
|
||||
testString: assert("How vexingly quick daft zebras jump!".match(nonAlphabetRegex).length == 6);
|
||||
- text: 你的正则表达式应该在<code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>找到12个非字母数字字符<code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>
|
||||
testString: 'assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(nonAlphabetRegex).length == 12, "Your regex should find 12 non-alphanumeric characters in <code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>");'
|
||||
testString: assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(nonAlphabetRegex).length == 12);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 匹配字母的字母
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>alphabetRegex</code>应该匹配35项。
|
||||
testString: 'assert(result.length == 35, "Your regex <code>alphabetRegex</code> should match 35 items.");'
|
||||
testString: assert(result.length == 35);
|
||||
- text: 你的正则表达式<code>alphabetRegex</code>应该使用全局标志。
|
||||
testString: 'assert(alphabetRegex.flags.match(/g/).length == 1, "Your regex <code>alphabetRegex</code> should use the global flag.");'
|
||||
testString: assert(alphabetRegex.flags.match(/g/).length == 1);
|
||||
- text: 你的正则表达式<code>alphabetRegex</code>应该使用不区分大小写的标志。
|
||||
testString: 'assert(alphabetRegex.flags.match(/i/).length == 1, "Your regex <code>alphabetRegex</code> should use the case insensitive flag.");'
|
||||
testString: assert(alphabetRegex.flags.match(/i/).length == 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 匹配文字字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>waldoRegex</code>应该找到<code>"Waldo"</code>
|
||||
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex <code>waldoRegex</code> should find <code>"Waldo"</code>");'
|
||||
testString: assert(waldoRegex.test(waldoIsHiding));
|
||||
- text: 你的正则表达式<code>waldoRegex</code>不应该搜索任何其他内容。
|
||||
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex <code>waldoRegex</code> should not search for anything else.");'
|
||||
testString: assert(!waldoRegex.test('Somewhere is hiding in this text.'));
|
||||
- text: 您应该与正则表达式执行文字字符串匹配。
|
||||
testString: 'assert(!/\/.*\/i/.test(code), "You should perform a literal string match with your regex.");'
|
||||
testString: assert(!/\/.*\/i/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 匹配非空白字符
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用全局标志。
|
||||
testString: 'assert(countNonWhiteSpace.global, "Your regex should use the global flag.");'
|
||||
testString: assert(countNonWhiteSpace.global);
|
||||
- text: 你的正则表达式应该使用速记字符
|
||||
testString: 'assert(/\\S/.test(countNonWhiteSpace.source), "Your regex should use the shorthand character <code>\S/code> to match all non-whitespace characters.");'
|
||||
testString: assert(/\\S/.test(countNonWhiteSpace.source));
|
||||
- text: 你的正则表达式应该在<code>"Men are from Mars and women are from Venus."</code>找到35个非空格<code>"Men are from Mars and women are from Venus."</code>
|
||||
testString: 'assert("Men are from Mars and women are from Venus.".match(countNonWhiteSpace).length == 35, "Your regex should find 35 non-spaces in <code>"Men are from Mars and women are from Venus."</code>");'
|
||||
testString: assert("Men are from Mars and women are from Venus.".match(countNonWhiteSpace).length == 35);
|
||||
- text: '你的正则表达式应该在<code>"Space: the final frontier."</code>找到23个非空格<code>"Space: the final frontier."</code>'
|
||||
testString: 'assert("Space: the final frontier.".match(countNonWhiteSpace).length == 23, "Your regex should find 23 non-spaces in <code>"Space: the final frontier."</code>");'
|
||||
testString: 'assert("Space: the final frontier.".match(countNonWhiteSpace).length == 23);'
|
||||
- text: 你的正则表达式应该在<code>"MindYourPersonalSpace"</code>找到21个非空格
|
||||
testString: 'assert("MindYourPersonalSpace".match(countNonWhiteSpace).length == 21, "Your regex should find 21 non-spaces in <code>"MindYourPersonalSpace"</code>");'
|
||||
testString: assert("MindYourPersonalSpace".match(countNonWhiteSpace).length == 21);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 匹配数字和字母的字母
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>myRegex</code>应该匹配17项。
|
||||
testString: 'assert(result.length == 17, "Your regex <code>myRegex</code> should match 17 items.");'
|
||||
testString: assert(result.length == 17);
|
||||
- text: 你的正则表达式<code>myRegex</code>应该使用全局标志。
|
||||
testString: 'assert(myRegex.flags.match(/g/).length == 1, "Your regex <code>myRegex</code> should use the global flag.");'
|
||||
testString: assert(myRegex.flags.match(/g/).length == 1);
|
||||
- text: 你的正则表达式<code>myRegex</code>应该使用不区分大小写的标志。
|
||||
testString: 'assert(myRegex.flags.match(/i/).length == 1, "Your regex <code>myRegex</code> should use the case insensitive flag.");'
|
||||
testString: assert(myRegex.flags.match(/i/).length == 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 将单个角色与多种可能性相匹配
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该找到所有25个元音。
|
||||
testString: 'assert(result.length == 25, "You should find all 25 vowels.");'
|
||||
testString: assert(result.length == 25);
|
||||
- text: 你的正则表达式<code>vowelRegex</code>应该使用一个字符类。
|
||||
testString: 'assert(/\[.*\]/.test(vowelRegex.source), "Your regex <code>vowelRegex</code> should use a character class.");'
|
||||
testString: assert(/\[.*\]/.test(vowelRegex.source));
|
||||
- text: 你的正则表达式<code>vowelRegex</code>应该使用全局标志。
|
||||
testString: 'assert(vowelRegex.flags.match(/g/).length == 1, "Your regex <code>vowelRegex</code> should use the global flag.");'
|
||||
testString: assert(vowelRegex.flags.match(/g/).length == 1);
|
||||
- text: 你的正则表达式<code>vowelRegex</code>应该使用不区分大小写的标志。
|
||||
testString: 'assert(vowelRegex.flags.match(/i/).length == 1, "Your regex <code>vowelRegex</code> should use the case insensitive flag.");'
|
||||
testString: assert(vowelRegex.flags.match(/i/).length == 1);
|
||||
- text: 你的正则表达式不应该与任何辅音匹配。
|
||||
testString: 'assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()), "Your regex should not match any consonants.");'
|
||||
testString: assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 匹配未指定的单个字符
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式<code>myRegex</code>应匹配9项。
|
||||
testString: 'assert(result.length == 9, "Your regex <code>myRegex</code> should match 9 items.");'
|
||||
testString: assert(result.length == 9);
|
||||
- text: 你的正则表达式<code>myRegex</code>应该使用全局标志。
|
||||
testString: 'assert(myRegex.flags.match(/g/).length == 1, "Your regex <code>myRegex</code> should use the global flag.");'
|
||||
testString: assert(myRegex.flags.match(/g/).length == 1);
|
||||
- text: 你的正则表达式<code>myRegex</code>应该使用不区分大小写的标志。
|
||||
testString: 'assert(myRegex.flags.match(/i/).length == 1, "Your regex <code>myRegex</code> should use the case insensitive flag.");'
|
||||
testString: assert(myRegex.flags.match(/i/).length == 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 匹配空白
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用全局标志。
|
||||
testString: 'assert(countWhiteSpace.global, "Your regex should use the global flag.");'
|
||||
testString: assert(countWhiteSpace.global);
|
||||
- text: 你的正则表达式应该使用速记字符
|
||||
testString: 'assert(/\\s/.test(countWhiteSpace.source), "Your regex should use the shorthand character <code>\s</code> to match all whitespace characters.");'
|
||||
testString: assert(/\\s/.test(countWhiteSpace.source));
|
||||
- text: 你的正则表达式应该在<code>"Men are from Mars and women are from Venus."</code>找到八个空格<code>"Men are from Mars and women are from Venus."</code>
|
||||
testString: 'assert("Men are from Mars and women are from Venus.".match(countWhiteSpace).length == 8, "Your regex should find eight spaces in <code>"Men are from Mars and women are from Venus."</code>");'
|
||||
testString: assert("Men are from Mars and women are from Venus.".match(countWhiteSpace).length == 8);
|
||||
- text: '你的正则表达式应该在<code>"Space: the final frontier."</code>找到三个空格<code>"Space: the final frontier."</code>'
|
||||
testString: 'assert("Space: the final frontier.".match(countWhiteSpace).length == 3, "Your regex should find three spaces in <code>"Space: the final frontier."</code>");'
|
||||
- text: ''
|
||||
testString: 'assert("MindYourPersonalSpace".match(countWhiteSpace) == null, "Your regex should find no spaces in <code>"MindYourPersonalSpace"</code>");'
|
||||
testString: 'assert("Space: the final frontier.".match(countWhiteSpace).length == 3);'
|
||||
- text: 您的正则表达式应该在<code>"MindYourPersonalSpace"</code>中找不到空格
|
||||
testString: assert("MindYourPersonalSpace".match(countWhiteSpace) == null);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 积极和消极的前瞻
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用两个积极的<code>lookaheads</code> 。
|
||||
testString: 'assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null, "Your regex should use two positive <code>lookaheads</code>.");'
|
||||
testString: assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null);
|
||||
- text: 你的正则表达式不应该匹配<code>"astronaut"</code>
|
||||
testString: 'assert(!pwRegex.test("astronaut"), "Your regex should not match <code>"astronaut"</code>");'
|
||||
testString: assert(!pwRegex.test("astronaut"));
|
||||
- text: 你的正则表达式不应该与<code>"airplanes"</code>匹配
|
||||
testString: 'assert(!pwRegex.test("airplanes"), "Your regex should not match <code>"airplanes"</code>");'
|
||||
testString: assert(!pwRegex.test("airplanes"));
|
||||
- text: 你的正则表达式不应该匹配<code>"banan1"</code>
|
||||
testString: 'assert(!pwRegex.test("banan1"), "Your regex should not match <code>"banan1"</code>");'
|
||||
testString: assert(!pwRegex.test("banan1"));
|
||||
- text: 你的正则表达式应该匹配<code>"bana12"</code>
|
||||
testString: 'assert(pwRegex.test("bana12"), "Your regex should match <code>"bana12"</code>");'
|
||||
testString: assert(pwRegex.test("bana12"));
|
||||
- text: 你的正则表达式应该匹配<code>"abc123"</code>
|
||||
testString: 'assert(pwRegex.test("abc123"), "Your regex should match <code>"abc123"</code>");'
|
||||
testString: assert(pwRegex.test("abc123"));
|
||||
- text: 你的正则表达式不应该匹配<code>"123"</code>
|
||||
testString: 'assert(!pwRegex.test("123"), "Your regex should not match <code>"123"</code>");'
|
||||
testString: assert(!pwRegex.test("123"));
|
||||
- text: 你的正则表达式不应该匹配<code>"1234"</code>
|
||||
testString: 'assert(!pwRegex.test("1234"), "Your regex should not match <code>"1234"</code>");'
|
||||
testString: assert(!pwRegex.test("1234"));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 从开始和结束中删除空格
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>result</code>应该等于<code>"Hello, World!"</code>'
|
||||
testString: 'assert(result == "Hello, World!", "<code>result</code> should equal to <code>"Hello, World!"</code>");'
|
||||
testString: assert(result == "Hello, World!");
|
||||
- text: 您不应该使用<code>.trim()</code>方法。
|
||||
testString: 'assert(!code.match(/\.trim\(.*?\)/), "You should not use the <code>.trim()</code> method.");'
|
||||
testString: assert(!code.match(/\.trim\([\s\S]*?\)/));
|
||||
- text: <code>result</code>变量不应设置为等于字符串。
|
||||
testString: 'assert(!code.match(/result\s*=\s*".*?"/), "The <code>result</code> variable should not be set equal to a string.");'
|
||||
testString: assert(!code.match(/result\s*=\s*".*?"/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,25 +18,25 @@ localeTitle: 使用捕获组重用模式
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用数字的速记字符类。
|
||||
testString: 'assert(reRegex.source.match(/\\d/), "Your regex should use the shorthand character class for digits.");'
|
||||
testString: assert(reRegex.source.match(/\\d/));
|
||||
- text: 您的正则表达式应该重复使用捕获组两次。
|
||||
testString: 'assert(reRegex.source.match(/\\\d/g).length === 2, "Your regex should reuse the capture group twice.");'
|
||||
testString: assert(reRegex.source.match(/\\1|\\2/g).length >= 2);
|
||||
- text: 你的正则表达式应该有两个空格来分隔这三个数字。
|
||||
testString: 'assert(reRegex.source.match(/\\s/g).length === 2, "Your regex should have two spaces separating the three numbers.");'
|
||||
testString: assert(reRegex.source.match(/ |\\s/g).length === 2 || reRegex.source.match(/\(\\s\)(?=.*\\(1|2))/g));
|
||||
- text: 你的正则表达式应该匹配<code>"42 42 42"</code> 。
|
||||
testString: 'assert(reRegex.test("42 42 42"), "Your regex should match <code>"42 42 42"</code>.");'
|
||||
testString: assert(reRegex.test("42 42 42"));
|
||||
- text: 你的正则表达式应该匹配<code>"100 100 100"</code> 。
|
||||
testString: 'assert(reRegex.test("100 100 100"), "Your regex should match <code>"100 100 100"</code>.");'
|
||||
testString: assert(reRegex.test("100 100 100"));
|
||||
- text: 你的正则表达式不应该匹配<code>"42 42 42 42"</code> 。
|
||||
testString: 'assert.equal(("42 42 42 42").match(reRegex.source), null, "Your regex should not match <code>"42 42 42 42"</code>.");'
|
||||
testString: assert.equal(("42 42 42 42").match(reRegex.source), null);
|
||||
- text: 你的正则表达式不应该匹配<code>"42 42"</code> 。
|
||||
testString: 'assert.equal(("42 42").match(reRegex.source), null, "Your regex should not match <code>"42 42"</code>.");'
|
||||
testString: assert.equal(("42 42").match(reRegex.source), null);
|
||||
- text: 你的正则表达式不应该匹配<code>"101 102 103"</code> 。
|
||||
testString: 'assert(!reRegex.test("101 102 103"), "Your regex should not match <code>"101 102 103"</code>.");'
|
||||
testString: assert(!reRegex.test("101 102 103"));
|
||||
- text: 你的正则表达式不应该匹配<code>"1 2 3"</code> 。
|
||||
testString: 'assert(!reRegex.test("1 2 3"), "Your regex should not match <code>"1 2 3"</code>.");'
|
||||
testString: assert(!reRegex.test("1 2 3"));
|
||||
- text: 你的正则表达式应匹配<code>"10 10 10"</code> 。
|
||||
testString: 'assert(reRegex.test("10 10 10"), "Your regex should match <code>"10 10 10"</code>.");'
|
||||
testString: assert(reRegex.test("10 10 10"));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 指定完全匹配数
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用大括号。
|
||||
testString: 'assert(timRegex.source.match(/{.*?}/).length > 0, "Your regex should use curly brackets.");'
|
||||
testString: assert(timRegex.source.match(/{.*?}/).length > 0);
|
||||
- text: 你的正则表达式不应该与<code>"Timber"</code>匹配
|
||||
testString: 'assert(!timRegex.test("Timber"), "Your regex should not match <code>"Timber"</code>");'
|
||||
testString: assert(!timRegex.test("Timber"));
|
||||
- text: 你的正则表达式不应该匹配<code>"Timmber"</code>
|
||||
testString: 'assert(!timRegex.test("Timmber"), "Your regex should not match <code>"Timmber"</code>");'
|
||||
testString: assert(!timRegex.test("Timmber"));
|
||||
- text: 你的正则表达式不应该匹配<code>"Timmmber"</code>
|
||||
testString: 'assert(!timRegex.test("Timmmber"), "Your regex should not match <code>"Timmmber"</code>");'
|
||||
testString: assert(!timRegex.test("Timmmber"));
|
||||
- text: 你的正则表达式应该匹配<code>"Timmmmber"</code>
|
||||
testString: 'assert(timRegex.test("Timmmmber"), "Your regex should match <code>"Timmmmber"</code>");'
|
||||
testString: assert(timRegex.test("Timmmmber"));
|
||||
- text: 你的正则表达式不应该与30 <code>m</code>的<code>"Timber"</code>相匹配。
|
||||
testString: 'assert(!timRegex.test("Ti" + "m".repeat(30) + "ber"), "Your regex should not match <code>"Timber"</code> with 30 <code>m</code>\"s in it.");'
|
||||
testString: assert(!timRegex.test("Ti" + "m".repeat(30) + "ber"));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,19 +18,19 @@ localeTitle: 仅指定较低的匹配数
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用大括号。
|
||||
testString: 'assert(haRegex.source.match(/{.*?}/).length > 0, "Your regex should use curly brackets.");'
|
||||
testString: assert(haRegex.source.match(/{.*?}/).length > 0);
|
||||
- text: 你的正则表达式不应该与<code>"Hazzah"</code>匹配
|
||||
testString: 'assert(!haRegex.test("Hazzah"), "Your regex should not match <code>"Hazzah"</code>");'
|
||||
testString: assert(!haRegex.test("Hazzah"));
|
||||
- text: 你的正则表达式不应该与<code>"Hazzzah"</code>匹配
|
||||
testString: 'assert(!haRegex.test("Hazzzah"), "Your regex should not match <code>"Hazzzah"</code>");'
|
||||
testString: assert(!haRegex.test("Hazzzah"));
|
||||
- text: 你的正则表达应该匹配<code>"Hazzzzah"</code>
|
||||
testString: 'assert(haRegex.test("Hazzzzah"), "Your regex should match <code>"Hazzzzah"</code>");'
|
||||
testString: assert("Hazzzzah".match(haRegex)[0].length === 8);
|
||||
- text: 你的正则表达应该匹配<code>"Hazzzzzah"</code>
|
||||
testString: 'assert(haRegex.test("Hazzzzzah"), "Your regex should match <code>"Hazzzzzah"</code>");'
|
||||
testString: assert("Hazzzzzah".match(haRegex)[0].length === 9);
|
||||
- text: 你的正则表达应该匹配<code>"Hazzzzzzah"</code>
|
||||
testString: 'assert(haRegex.test("Hazzzzzzah"), "Your regex should match <code>"Hazzzzzzah"</code>");'
|
||||
testString: assert("Hazzzzzzah".match(haRegex)[0].length === 10);
|
||||
- text: 你的正则表达式应该匹配<code>"Hazzah"</code>和30个<code>z</code> 。
|
||||
testString: 'assert(haRegex.test("Ha" + "z".repeat(30) + "ah"), "Your regex should match <code>"Hazzah"</code> with 30 <code>z</code>\"s in it.");'
|
||||
testString: assert("Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah".match(haRegex)[0].length === 34);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,19 +18,19 @@ localeTitle: 指定上下匹配数
|
||||
```yml
|
||||
tests:
|
||||
- text: 你的正则表达式应该使用大括号。
|
||||
testString: 'assert(ohRegex.source.match(/{.*?}/).length > 0, "Your regex should use curly brackets.");'
|
||||
testString: assert(ohRegex.source.match(/{.*?}/).length > 0);
|
||||
- text: 你的正则表达式不应该匹配<code>"Ohh no"</code>
|
||||
testString: 'assert(!ohRegex.test("Ohh no"), "Your regex should not match <code>"Ohh no"</code>");'
|
||||
testString: assert(!ohRegex.test("Ohh no"));
|
||||
- text: 你的正则表达式应该匹配<code>"Ohhh no"</code>
|
||||
testString: 'assert(ohRegex.test("Ohhh no"), "Your regex should match <code>"Ohhh no"</code>");'
|
||||
testString: assert("Ohhh no".match(ohRegex)[0].length === 7);
|
||||
- text: 你的正则表达式应该匹配<code>"Ohhhh no"</code>
|
||||
testString: 'assert(ohRegex.test("Ohhhh no"), "Your regex should match <code>"Ohhhh no"</code>");'
|
||||
testString: assert("Ohhhh no".match(ohRegex)[0].length === 8);
|
||||
- text: 你的正则表达式应该匹配<code>"Ohhhhh no"</code>
|
||||
testString: 'assert(ohRegex.test("Ohhhhh no"), "Your regex should match <code>"Ohhhhh no"</code>");'
|
||||
testString: assert("Ohhhhh no".match(ohRegex)[0].length === 9);
|
||||
- text: 你的正则表达式应该匹配<code>"Ohhhhhh no"</code>
|
||||
testString: 'assert(ohRegex.test("Ohhhhhh no"), "Your regex should match <code>"Ohhhhhh no"</code>");'
|
||||
testString: assert("Ohhhhhh no".match(ohRegex)[0].length === 10);
|
||||
- text: 你的正则表达式不应该匹配<code>"Ohhhhhhh no"</code>
|
||||
testString: 'assert(!ohRegex.test("Ohhhhhhh no"), "Your regex should not match <code>"Ohhhhhhh no"</code>");'
|
||||
testString: assert(!ohRegex.test("Ohhhhhhh no"));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 使用捕获组进行搜索和替换
|
||||
```yml
|
||||
tests:
|
||||
- text: 您应该使用<code>.replace()</code>来搜索和替换。
|
||||
testString: 'assert(code.match(/\.replace\(.*\)/), "You should use <code>.replace()</code> to search and replace.");'
|
||||
testString: assert(code.match(/\.replace\(.*\)/));
|
||||
- text: 你的正则表达式应该改变<code>"This sandwich is good."</code> <code>"This sandwich is okey-dokey."</code>
|
||||
testString: 'assert(result == "This sandwich is okey-dokey." && replaceText === "okey-dokey", "Your regex should change <code>"This sandwich is good."</code> to <code>"This sandwich is okey-dokey."</code>");'
|
||||
testString: assert(result == "This sandwich is okey-dokey." && replaceText === "okey-dokey");
|
||||
- text: 你不应该改变最后一行。
|
||||
testString: 'assert(code.match(/result\s*=\s*huhText\.replace\(.*?\)/), "You should not change the last line.");'
|
||||
testString: assert(code.match(/result\s*=\s*huhText\.replace\(.*?\)/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用测试方法
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该使用<code>.test()</code>来测试正则表达式。
|
||||
testString: 'assert(code.match(/myRegex.test\(\s*myString\s*\)/), "You should use <code>.test()</code> to test the regex.");'
|
||||
testString: assert(code.match(/myRegex.test\(\s*myString\s*\)/));
|
||||
- text: 您的结果应该返回<code>true</code> 。
|
||||
testString: 'assert(result === true, "Your result should return <code>true</code>.");'
|
||||
testString: assert(result === true);
|
||||
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user