From 095188215f41a27f9e833a2b8cd7bdda33b5fd72 Mon Sep 17 00:00:00 2001 From: Kristofer Koishigawa Date: Mon, 1 Apr 2019 22:49:13 +0900 Subject: [PATCH] fix(challenges): Regex Asterisk Challenge (#34800) * fix(challenges): Fixes description and adds tests to close #17872. * fix(challenges): Removed unnecessary string arguments from testString * fix: improved challenge instr and tests --- ...s-that-occur-zero-or-more-times.english.md | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times.english.md index 7148138756..21a69163c9 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times.english.md @@ -13,7 +13,7 @@ The character to do this is the asterisk or star: -Create a regex chewieRegex that uses the * character to match all the upper and lowercase "a" characters in chewieQuote. Your regex does not need flags, and it should not match any of the other quotes. +For this challenge, chewieQuote has been initialized as "Aaaaaaaaaaaaaaaarrrgh!" behind the scenes. Create a regex chewieRegex that uses the * character to match an uppercase "A" character immediately followed by zero or more lowercase "a" characters in chewieQuote. Your regex does not need flags or character classes, and it should not match any of the other quotes. ## Tests @@ -22,15 +22,17 @@ Create a regex chewieRegex that uses the * character t ```yml tests: - text: Your regex chewieRegex should use the * character to match zero or more a characters. - testString: assert(/\*/.test(chewieRegex.source), 'Your regex chewieRegex should use the * character to match zero or more a characters.'); - - text: Your regex chewieRegex should match 16 characters. - testString: assert(result[0].length === 16, 'Your regex chewieRegex should match 16 characters.'); - - text: Your regex should match "Aaaaaaaaaaaaaaaa". - testString: assert(result[0] === 'Aaaaaaaaaaaaaaaa', 'Your regex should match "Aaaaaaaaaaaaaaaa".'); - - text: Your regex should not match any characters in "He made a fair move. Screaming about it can't help you." - testString: assert(!"He made a fair move. Screaming about it can\'t help you.".match(chewieRegex), 'Your regex should not match any characters in "He made a fair move. Screaming about it can't help you."'); - - text: Your regex should not match any characters in "Let him have it. It's not wise to upset a Wookiee." - testString: assert(!"Let him have it. It\'s not wise to upset a Wookiee.".match(chewieRegex), 'Your regex should not match any characters in "Let him have it. It's not wise to upset a Wookiee."'); + testString: assert(/\*/.test(chewieRegex.source)); + - text: Your regex should match "A" in chewieQuote. + testString: assert(result[0][0] === 'A'); + - text: Your regex should match "Aaaaaaaaaaaaaaaa" in chewieQuote. + testString: assert(result[0] === 'Aaaaaaaaaaaaaaaa'); + - text: Your regex chewieRegex should match 16 characters in chewieQuote. + testString: assert(result[0].length === 16); + - text: Your regex should not match any characters in "He made a fair move. Screaming about it can't help you." + testString: assert(!"He made a fair move. Screaming about it can't help you.".match(chewieRegex)); + - text: Your regex should not match any characters in "Let him have it. It's not wise to upset a Wookiee." + testString: assert(!"Let him have it. It's not wise to upset a Wookiee.".match(chewieRegex)); ``` @@ -42,14 +44,20 @@ tests:
```js -let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!"; -let chewieRegex = /change/; // Change this line +let chewieRegex = /change/; // Only change this line let result = chewieQuote.match(chewieRegex); ```
+## Before Test +
+```js +const chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!"; +``` + +
@@ -57,7 +65,6 @@ let result = chewieQuote.match(chewieRegex);
```js - let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!"; let chewieRegex = /Aa*/; let result = chewieQuote.match(chewieRegex); ```