feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0095583028
commit
ee1e8abd87
@ -3,6 +3,7 @@ id: 587d7dba367417b2b2512ba8
|
||||
title: 检查全部或无
|
||||
challengeType: 1
|
||||
forumTopicId: 301338
|
||||
dashedName: check-for-all-or-none
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -51,5 +52,20 @@ assert(favRegex.test('favourite'));
|
||||
assert(!favRegex.test('fav'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let favWord = "favorite";
|
||||
let favRegex = /change/; // Change this line
|
||||
let result = favRegex.test(favWord);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let favWord = "favorite";
|
||||
let favRegex = /favou?r/;
|
||||
let result = favRegex.test(favWord);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 5c3dda8b4d8df89bea71600f
|
||||
title: 检查混合字符组
|
||||
challengeType: 1
|
||||
forumTopicId: 301339
|
||||
dashedName: check-for-mixed-grouping-of-characters
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -61,5 +62,21 @@ result 应该返回 `true`。
|
||||
assert(result === true);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let myString = "Eleanor Roosevelt";
|
||||
let myRegex = /False/; // Change this line
|
||||
let result = false; // Change this line
|
||||
// After passing the challenge experiment with myString and see how the grouping works
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let myString = "Eleanor Roosevelt";
|
||||
let myRegex = /(Franklin|Eleanor).*Roosevelt/;
|
||||
let result = myRegex.test(myString);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db4367417b2b2512b92
|
||||
title: 提取匹配项
|
||||
challengeType: 1
|
||||
forumTopicId: 301340
|
||||
dashedName: extract-matches
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -44,5 +45,20 @@ assert(codingRegex.source === 'coding');
|
||||
assert(code.match(/\.match\(.*\)/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let extractStr = "Extract the word 'coding' from this string.";
|
||||
let codingRegex = /change/; // Change this line
|
||||
let result = extractStr; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let extractStr = "Extract the word 'coding' from this string.";
|
||||
let codingRegex = /coding/; // Change this line
|
||||
let result = extractStr.match(codingRegex); // Change this line
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db6367417b2b2512b9b
|
||||
title: 用惰性匹配来查找字符
|
||||
challengeType: 1
|
||||
forumTopicId: 301341
|
||||
dashedName: find-characters-with-lazy-matching
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -30,5 +31,20 @@ forumTopicId: 301341
|
||||
assert(result[0] == '<h1>');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let text = "<h1>Winter is coming</h1>";
|
||||
let myRegex = /<.*>/; // Change this line
|
||||
let result = text.match(myRegex);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let text = "<h1>Winter is coming</h1>";
|
||||
let myRegex = /<.*?>/; // Change this line
|
||||
let result = text.match(myRegex);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db4367417b2b2512b93
|
||||
title: 全局匹配
|
||||
challengeType: 1
|
||||
forumTopicId: 301342
|
||||
dashedName: find-more-than-the-first-match
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -63,5 +64,20 @@ assert(
|
||||
assert(result.length == 2);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let twinkleStar = "Twinkle, twinkle, little star";
|
||||
let starRegex = /change/; // Change this line
|
||||
let result = twinkleStar; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let twinkleStar = "Twinkle, twinkle, little star";
|
||||
let starRegex = /twinkle/gi;
|
||||
let result = twinkleStar.match(starRegex);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db7367417b2b2512b9c
|
||||
title: 在狩猎中找到一个或多个罪犯
|
||||
challengeType: 1
|
||||
forumTopicId: 301343
|
||||
dashedName: find-one-or-more-criminals-in-a-hunt
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -90,5 +91,16 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let reCriminals = /./; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let reCriminals = /C+/; // Change this line
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db4367417b2b2512b91
|
||||
title: 匹配时忽略大小写
|
||||
challengeType: 1
|
||||
forumTopicId: 301344
|
||||
dashedName: ignore-case-while-matching
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -79,5 +80,20 @@ assert(fccRegex.test('FrEeCodECamp'));
|
||||
assert(fccRegex.test('FReeCodeCAmp'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let myString = "freeCodeCamp";
|
||||
let fccRegex = /change/; // Change this line
|
||||
let result = fccRegex.test(myString);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let myString = "freeCodeCamp";
|
||||
let fccRegex = /freecodecamp/i; // Change this line
|
||||
let result = fccRegex.test(myString);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db4367417b2b2512b90
|
||||
title: 同时用多种模式匹配文字字符串
|
||||
challengeType: 1
|
||||
forumTopicId: 301345
|
||||
dashedName: match-a-literal-string-with-different-possibilities
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -63,5 +64,20 @@ assert(petRegex.test('Alice has a pet fish.'));
|
||||
assert(!petRegex.test('Jimmy has a pet computer.'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let petString = "James has a pet cat.";
|
||||
let petRegex = /change/; // Change this line
|
||||
let result = petRegex.test(petString);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let petString = "James has a pet cat.";
|
||||
let petRegex = /dog|cat|bird|fish/; // Change this line
|
||||
let result = petRegex.test(petString);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db7367417b2b2512b9f
|
||||
title: 匹配所有的字母和数字
|
||||
challengeType: 1
|
||||
forumTopicId: 301346
|
||||
dashedName: match-all-letters-and-numbers
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -74,5 +75,20 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let quoteSample = "The five boxing wizards jump quickly.";
|
||||
let alphabetRegexV2 = /change/; // Change this line
|
||||
let result = quoteSample.match(alphabetRegexV2).length;
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let quoteSample = "The five boxing wizards jump quickly.";
|
||||
let alphabetRegexV2 = /\w/g; // Change this line
|
||||
let result = quoteSample.match(alphabetRegexV2).length;
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db8367417b2b2512ba1
|
||||
title: 匹配所有非数字
|
||||
challengeType: 1
|
||||
forumTopicId: 301347
|
||||
dashedName: match-all-non-numbers
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -65,5 +66,20 @@ assert('21 Jump Street'.match(noNumRegex).length == 12);
|
||||
assert('2001: A Space Odyssey'.match(noNumRegex).length == 17);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let movieName = "2001: A Space Odyssey";
|
||||
let noNumRegex = /change/; // Change this line
|
||||
let result = movieName.match(noNumRegex).length;
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let movieName = "2001: A Space Odyssey";
|
||||
let noNumRegex = /\D/g; // Change this line
|
||||
let result = movieName.match(noNumRegex).length;
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 5d712346c441eddfaeb5bdef
|
||||
title: 匹配所有数字
|
||||
challengeType: 1
|
||||
forumTopicId: 18181
|
||||
dashedName: match-all-numbers
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -65,5 +66,20 @@ assert('21 Jump Street'.match(numRegex).length == 2);
|
||||
assert('2001: A Space Odyssey'.match(numRegex).length == 4);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let movieName = "2001: A Space Odyssey";
|
||||
let numRegex = /change/; // Change this line
|
||||
let result = movieName.match(numRegex).length;
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let movieName = "2001: A Space Odyssey";
|
||||
let numRegex = /\d/g; // Change this line
|
||||
let result = movieName.match(numRegex).length;
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db5367417b2b2512b94
|
||||
title: 用通配符.匹配任何内容
|
||||
challengeType: 1
|
||||
forumTopicId: 301348
|
||||
dashedName: match-anything-with-wildcard-period
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -89,5 +90,20 @@ assert(!unRegex.test('There is a bug in my code.'));
|
||||
assert(!unRegex.test('Can me if you can.'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let exampleStr = "Let's have fun with regular expressions!";
|
||||
let unRegex = /change/; // Change this line
|
||||
let result = unRegex.test(exampleStr);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let exampleStr = "Let's have fun with regular expressions!";
|
||||
let unRegex = /.un/; // Change this line
|
||||
let result = unRegex.test(exampleStr);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db7367417b2b2512b9d
|
||||
title: 匹配字符串的开头
|
||||
challengeType: 1
|
||||
forumTopicId: 301349
|
||||
dashedName: match-beginning-string-patterns
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -51,5 +52,20 @@ assert(calRegex.test('Cal and Ricky both like racing.'));
|
||||
assert(!calRegex.test('Ricky and Cal both like racing.'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let rickyAndCal = "Cal and Ricky both like racing.";
|
||||
let calRegex = /change/; // Change this line
|
||||
let result = calRegex.test(rickyAndCal);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let rickyAndCal = "Cal and Ricky both like racing.";
|
||||
let calRegex = /^Cal/; // Change this line
|
||||
let result = calRegex.test(rickyAndCal);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db6367417b2b2512b99
|
||||
title: 匹配出现一次或多次的字符
|
||||
challengeType: 1
|
||||
forumTopicId: 301350
|
||||
dashedName: match-characters-that-occur-one-or-more-times
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -39,5 +40,20 @@ assert(result.length == 2);
|
||||
assert(result[0] == 'ss' && result[1] == 'ss');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let difficultSpelling = "Mississippi";
|
||||
let myRegex = /change/; // Change this line
|
||||
let result = difficultSpelling.match(myRegex);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let difficultSpelling = "Mississippi";
|
||||
let myRegex = /s+/g; // Change this line
|
||||
let result = difficultSpelling.match(myRegex);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db6367417b2b2512b9a
|
||||
title: 匹配出现零次或多次的字符
|
||||
challengeType: 1
|
||||
forumTopicId: 301351
|
||||
dashedName: match-characters-that-occur-zero-or-more-times
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -67,5 +68,27 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --before-user-code--
|
||||
|
||||
```js
|
||||
const chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
// Only change code below this line
|
||||
let chewieRegex = /change/; // Change this line
|
||||
// Only change code above this line
|
||||
|
||||
let result = chewieQuote.match(chewieRegex);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let chewieRegex = /Aa*/;
|
||||
let result = chewieQuote.match(chewieRegex);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db7367417b2b2512b9e
|
||||
title: 匹配字符串的末尾
|
||||
challengeType: 1
|
||||
forumTopicId: 301352
|
||||
dashedName: match-ending-string-patterns
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -46,5 +47,20 @@ assert(lastRegex.flags == '');
|
||||
assert(lastRegex.test('The last car on a train is the caboose'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let caboose = "The last car on a train is the caboose";
|
||||
let lastRegex = /change/; // Change this line
|
||||
let result = lastRegex.test(caboose);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let caboose = "The last car on a train is the caboose";
|
||||
let lastRegex = /caboose$/; // Change this line
|
||||
let result = lastRegex.test(caboose);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db8367417b2b2512ba0
|
||||
title: 匹配除了字母和数字的所有符号
|
||||
challengeType: 1
|
||||
forumTopicId: 301353
|
||||
dashedName: match-everything-but-letters-and-numbers
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -70,5 +71,20 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let quoteSample = "The five boxing wizards jump quickly.";
|
||||
let nonAlphabetRegex = /change/; // Change this line
|
||||
let result = quoteSample.match(nonAlphabetRegex).length;
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let quoteSample = "The five boxing wizards_jump quickly.";
|
||||
let nonAlphabetRegex = /\W/g; // Change this line
|
||||
let result = quoteSample.match(nonAlphabetRegex).length;
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db5367417b2b2512b96
|
||||
title: 匹配字母表中的字母
|
||||
challengeType: 1
|
||||
forumTopicId: 301354
|
||||
dashedName: match-letters-of-the-alphabet
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -50,5 +51,20 @@ assert(alphabetRegex.flags.match(/g/).length == 1);
|
||||
assert(alphabetRegex.flags.match(/i/).length == 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let quoteSample = "The quick brown fox jumps over the lazy dog.";
|
||||
let alphabetRegex = /change/; // Change this line
|
||||
let result = alphabetRegex; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let quoteSample = "The quick brown fox jumps over the lazy dog.";
|
||||
let alphabetRegex = /[a-z]/gi; // Change this line
|
||||
let result = quoteSample.match(alphabetRegex); // Change this line
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db3367417b2b2512b8f
|
||||
title: 匹配文字字符串
|
||||
challengeType: 1
|
||||
forumTopicId: 301355
|
||||
dashedName: match-literal-strings
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -50,5 +51,20 @@ assert(!waldoRegex.test('Somewhere is hiding in this text.'));
|
||||
assert(!/\/.*\/i/.test(code));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
||||
let waldoRegex = /search/; // Change this line
|
||||
let result = waldoRegex.test(waldoIsHiding);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
||||
let waldoRegex = /Waldo/; // Change this line
|
||||
let result = waldoRegex.test(waldoIsHiding);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db9367417b2b2512ba4
|
||||
title: 匹配非空白字符
|
||||
challengeType: 1
|
||||
forumTopicId: 18210
|
||||
dashedName: match-non-whitespace-characters
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -56,5 +57,20 @@ assert('Space: the final frontier.'.match(countNonWhiteSpace).length == 23);
|
||||
assert('MindYourPersonalSpace'.match(countNonWhiteSpace).length == 21);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let sample = "Whitespace is important in separating words";
|
||||
let countNonWhiteSpace = /change/; // Change this line
|
||||
let result = sample.match(countNonWhiteSpace);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let sample = "Whitespace is important in separating words";
|
||||
let countNonWhiteSpace = /\S/g; // Change this line
|
||||
let result = sample.match(countNonWhiteSpace);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db5367417b2b2512b97
|
||||
title: 匹配字母表中的数字和字母
|
||||
challengeType: 1
|
||||
forumTopicId: 301356
|
||||
dashedName: match-numbers-and-letters-of-the-alphabet
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -44,5 +45,20 @@ assert(myRegex.flags.match(/g/).length == 1);
|
||||
assert(myRegex.flags.match(/i/).length == 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let quoteSample = "Blueberry 3.141592653s are delicious.";
|
||||
let myRegex = /change/; // Change this line
|
||||
let result = myRegex; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let quoteSample = "Blueberry 3.141592653s are delicious.";
|
||||
let myRegex = /[h-s2-6]/gi; // Change this line
|
||||
let result = quoteSample.match(myRegex); // Change this line
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db5367417b2b2512b95
|
||||
title: 将单个字符与多种可能性匹配
|
||||
challengeType: 1
|
||||
forumTopicId: 301357
|
||||
dashedName: match-single-character-with-multiple-possibilities
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -64,5 +65,20 @@ assert(vowelRegex.flags.match(/i/).length == 1);
|
||||
assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
|
||||
let vowelRegex = /change/; // Change this line
|
||||
let result = vowelRegex; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
|
||||
let vowelRegex = /[aeiou]/gi; // Change this line
|
||||
let result = quoteSample.match(vowelRegex); // Change this line
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db6367417b2b2512b98
|
||||
title: 匹配单个未指定的字符
|
||||
challengeType: 1
|
||||
forumTopicId: 301358
|
||||
dashedName: match-single-characters-not-specified
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -37,5 +38,20 @@ assert(myRegex.flags.match(/g/).length == 1);
|
||||
assert(myRegex.flags.match(/i/).length == 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let quoteSample = "3 blind mice.";
|
||||
let myRegex = /change/; // Change this line
|
||||
let result = myRegex; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let quoteSample = "3 blind mice.";
|
||||
let myRegex = /[^0-9aeiou]/gi; // Change this line
|
||||
let result = quoteSample.match(myRegex); // Change this line
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db8367417b2b2512ba3
|
||||
title: 匹配空白字符
|
||||
challengeType: 1
|
||||
forumTopicId: 301359
|
||||
dashedName: match-whitespace
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -57,5 +58,20 @@ assert('Space: the final frontier.'.match(countWhiteSpace).length == 3);
|
||||
assert('MindYourPersonalSpace'.match(countWhiteSpace) == null);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let sample = "Whitespace is important in separating words";
|
||||
let countWhiteSpace = /change/; // Change this line
|
||||
let result = sample.match(countWhiteSpace);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let sample = "Whitespace is important in separating words";
|
||||
let countWhiteSpace = /\s/g;
|
||||
let result = sample.match(countWhiteSpace);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7dba367417b2b2512ba9
|
||||
title: 正向先行断言和负向先行断言
|
||||
challengeType: 1
|
||||
forumTopicId: 301360
|
||||
dashedName: positive-and-negative-lookahead
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -100,5 +101,18 @@ assert(!pwRegex.test('8pass99'));
|
||||
assert(!pwRegex.test('12abcde'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let sampleWord = "astronaut";
|
||||
let pwRegex = /change/; // Change this line
|
||||
let result = pwRegex.test(sampleWord);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
var pwRegex = /^\D(?=\w{5})(?=\w*\d{2})/;
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7dbb367417b2b2512bac
|
||||
title: 删除开头和结尾的空白
|
||||
challengeType: 1
|
||||
forumTopicId: 301362
|
||||
dashedName: remove-whitespace-from-start-and-end
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -36,5 +37,20 @@ assert(!code.match(/\.trim\(.*?\)/));
|
||||
assert(!code.match(/result\s*=\s*".*?"/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let hello = " Hello, World! ";
|
||||
let wsRegex = /change/; // Change this line
|
||||
let result = hello; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let hello = " Hello, World! ";
|
||||
let wsRegex = /^(\s+)(.+[^\s])(\s+)$/;
|
||||
let result = hello.replace(wsRegex, '$2');
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db8367417b2b2512ba2
|
||||
title: 限制可能的用户名
|
||||
challengeType: 1
|
||||
forumTopicId: 301363
|
||||
dashedName: restrict-possible-usernames
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -91,5 +92,20 @@ assert(userCheck.test('Z97'));
|
||||
assert(!userCheck.test('c57bT3'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let username = "JackOfAllTrades";
|
||||
let userCheck = /change/; // Change this line
|
||||
let result = userCheck.test(username);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let username = "JackOfAllTrades";
|
||||
const userCheck = /^[a-z]([0-9]{2,}|[a-z]+\d*)$/i;
|
||||
let result = userCheck.test(username);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7dbb367417b2b2512baa
|
||||
title: 使用捕获组重用模式
|
||||
challengeType: 1
|
||||
forumTopicId: 301364
|
||||
dashedName: reuse-patterns-using-capture-groups
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -93,5 +94,20 @@ assert(!reRegex.test('1 2 3'));
|
||||
assert(reRegex.test('10 10 10'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let repeatNum = "42 42 42";
|
||||
let reRegex = /change/; // Change this line
|
||||
let result = reRegex.test(repeatNum);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let repeatNum = "42 42 42";
|
||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||
let result = reRegex.test(repeatNum);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db9367417b2b2512ba7
|
||||
title: 指定匹配的确切数量
|
||||
challengeType: 1
|
||||
forumTopicId: 301365
|
||||
dashedName: specify-exact-number-of-matches
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -65,5 +66,20 @@ assert(timRegex.test('Timmmmber'));
|
||||
assert(!timRegex.test('Ti' + 'm'.repeat(30) + 'ber'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let timStr = "Timmmmber";
|
||||
let timRegex = /change/; // Change this line
|
||||
let result = timRegex.test(timStr);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let timStr = "Timmmmber";
|
||||
let timRegex = /Tim{4}ber/; // Change this line
|
||||
let result = timRegex.test(timStr);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db9367417b2b2512ba6
|
||||
title: 只指定匹配的下限
|
||||
challengeType: 1
|
||||
forumTopicId: 301366
|
||||
dashedName: specify-only-the-lower-number-of-matches
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -71,5 +72,20 @@ assert('Hazzzzzzah'.match(haRegex)[0].length === 10);
|
||||
assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let haStr = "Hazzzzah";
|
||||
let haRegex = /change/; // Change this line
|
||||
let result = haRegex.test(haStr);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let haStr = "Hazzzzah";
|
||||
let haRegex = /Haz{4,}ah/; // Change this line
|
||||
let result = haRegex.test(haStr);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db9367417b2b2512ba5
|
||||
title: 指定匹配的上限和下限
|
||||
challengeType: 1
|
||||
forumTopicId: 301367
|
||||
dashedName: specify-upper-and-lower-number-of-matches
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -69,5 +70,20 @@ assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
|
||||
assert(!ohRegex.test('Ohhhhhhh no'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let ohStr = "Ohhh no";
|
||||
let ohRegex = /change/; // Change this line
|
||||
let result = ohRegex.test(ohStr);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let ohStr = "Ohhh no";
|
||||
let ohRegex = /Oh{3,6} no/; // Change this line
|
||||
let result = ohRegex.test(ohStr);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7dbb367417b2b2512bab
|
||||
title: 使用捕获组搜索和替换
|
||||
challengeType: 1
|
||||
forumTopicId: 301368
|
||||
dashedName: use-capture-groups-to-search-and-replace
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -51,5 +52,22 @@ assert(
|
||||
assert(code.match(/result\s*=\s*huhText\.replace\(.*?\)/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let str = "one two three";
|
||||
let fixRegex = /change/; // Change this line
|
||||
let replaceText = ""; // Change this line
|
||||
let result = str.replace(fixRegex, replaceText);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let str = "one two three";
|
||||
let fixRegex = /(\w+) (\w+) (\w+)/g; // Change this line
|
||||
let replaceText = "$3 $2 $1"; // Change this line
|
||||
let result = str.replace(fixRegex, replaceText);
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ id: 587d7db3367417b2b2512b8e
|
||||
title: 使用测试方法
|
||||
challengeType: 1
|
||||
forumTopicId: 301369
|
||||
dashedName: using-the-test-method
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -38,5 +39,20 @@ assert(code.match(/myRegex.test\(\s*myString\s*\)/));
|
||||
assert(result === true);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
let myString = "Hello, World!";
|
||||
let myRegex = /Hello/;
|
||||
let result = myRegex; // Change this line
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
let myString = "Hello, World!";
|
||||
let myRegex = /Hello/;
|
||||
let result = myRegex.test(myString); // Change this line
|
||||
```
|
||||
|
Reference in New Issue
Block a user