* 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>
2.3 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7db6367417b2b2512b9a | Match Characters that Occur Zero or More Times | 1 | 301351 | match-characters-that-occur-zero-or-more-times |
--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 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
--instructions--
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.
--hints--
Your regex chewieRegex
should use the *
character to match zero or more a
characters.
assert(/\*/.test(chewieRegex.source));
Your regex should match "A"
in chewieQuote
.
assert(result[0][0] === 'A');
Your regex should match "Aaaaaaaaaaaaaaaa"
in chewieQuote
.
assert(result[0] === 'Aaaaaaaaaaaaaaaa');
Your regex chewieRegex
should match 16 characters in chewieQuote
.
assert(result[0].length === 16);
Your regex should not match any characters in "He made a fair move. Screaming about it can't help you."
assert(
!"He made a fair move. Screaming about it can't help you.".match(chewieRegex)
);
Your regex should not match any characters in "Let him have it. It's not wise to upset a Wookiee."
assert(
!"Let him have it. It's not wise to upset a Wookiee.".match(chewieRegex)
);
--seed--
--before-user-code--
const chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
--seed-contents--
// Only change code below this line
let chewieRegex = /change/; // Change this line
// Only change code above this line
let result = chewieQuote.match(chewieRegex);
--solutions--
let chewieRegex = /Aa*/;
let result = chewieQuote.match(chewieRegex);