diff --git a/challenges/02-javascript-algorithms-and-data-structures/regular-expressions.json b/challenges/02-javascript-algorithms-and-data-structures/regular-expressions.json index 893067c4ee..162ebe6bba 100644 --- a/challenges/02-javascript-algorithms-and-data-structures/regular-expressions.json +++ b/challenges/02-javascript-algorithms-and-data-structures/regular-expressions.json @@ -385,24 +385,21 @@ "description": [ "The last challenge used the plus + sign to look for characters that occur one or more times. There's also an option that matches characters that occur zero or more times.", "The character to do this is the asterisk or star: *.", - "
let sWord1 = \"seed\";
let sWord2 = \"saw\";
let kWord = \"kite\";
let sRegex = /s.*/; // Searches for words starting with s
sRegex.test(sWord1); // Returns true
sRegex.test(sWord2); // Returns true
sRegex.test(kWord); // Returns false
", + "
let soccerWord = \"gooooooooal!\";
let gPhrase = \"gut feeling\";
let oPhrase = \"over the moon\";
let goRegex = /go*/;
soccerWord.match(goRegex); // Returns [\"goooooooo\"]
gPhrase.match(goRegex); // Returns [\"g\"]
oPhrase.match(goRegex); // Returns null
", "
", - "Create a regex starWarsRegex that uses the * character to match all the movie titles that start with \"Star Wars\". Your regex does not need flags." + "Create a regex chewieRegex that uses the * character to match all the upper and lower\"a\" characters in chewieQuote. Your regex does not need flags, and it should not match any of the other quotes." ], "challengeSeed": [ - "let starWars = \"Star Wars\";", - "let starWarsRegex = /change/; // Change this line", - "let result = starWars.match(starWarsRegex);" + "let chewieQuote = \"Aaaaaaaaaaaaaaaarrrgh!\";", + "let chewieRegex = /change/; // Change this line", + "let result = chewieQuote.match(chewieRegex);" ], "tests": [ - "assert(starWarsRegex.test(\"Star Wars: The Phantom Menace\"), 'message: Your regex should match \"Star Wars: The Phantom Menace\".');", - "assert(starWarsRegex.test(\"Star Wars: Attack of the Clones\"), 'message: Your regex should match \"Star Wars: Attack of the Clones\".');", - "assert(starWarsRegex.test(\"Star Wars: Revenge of the Sith\"), 'message: Your regex should match \"Star Wars: Revenge of the Sith\".');", - "assert(starWarsRegex.test(\"Star Wars: A New Hope\"), 'message: Your regex should match \"Star Wars: A New Hope\".');", - "assert(starWarsRegex.test(\"Star Wars: The Empire Strikes Back\"), 'message: Your regex should match \"Star Wars: The Empire Strikes Back\".');", - "assert(starWarsRegex.test(\"Star Wars: Return of the Jedi\"), 'message: Your regex should match \"Star Wars: Return of the Jedi\".');", - "assert(starWarsRegex.test(\"Star Wars: The Force Awakens\"), 'message: Your regex should match \"Star Wars: The Force Awakens\".');", - "assert(!starWarsRegex.test(\"The Clone Wars\"), 'message: Your regex should not match \"The Clone Wars\"');" + "assert(/\\*/.test(chewieRegex.source), 'message: Your regex chewieRegex should use the * character to match zero or more a characters.');", + "assert(result[0].length === 16, 'message: Your regex chewieRegex should match 16 characters.');", + "assert(result[0] === 'Aaaaaaaaaaaaaaaa', 'message: Your regex should match \"Aaaaaaaaaaaaaaaa\".');", + "assert(!\"He made a fair move. Screaming about it can\\'t help you.\".match(chewieRegex), 'message: Your regex should not match any characters in \"He made a fair move. Screaming about it can't help you.\"');", + "assert(!\"Let him have it. It\\'s not wise to upset a Wookiee.\".match(chewieRegex), 'message: Your regex should not match any characters in \"Let him have it. It's not wise to upset a Wookiee.\"');" ], "solutions": [], "hints": [],