2.7 KiB
2.7 KiB
id | title | challengeType |
---|---|---|
587d7db6367417b2b2512b9a | Match Characters that Occur Zero or More Times | 1 |
Description
+
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
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.
Tests
tests:
- text: 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), 'Your regex <code>chewieRegex</code> should use the <code>*</code> character to match zero or more <code>a</code> characters.');
- text: Your regex <code>chewieRegex</code> should match 16 characters.
testString: assert(result[0].length === 16, 'Your regex <code>chewieRegex</code> should match 16 characters.');
- text: Your regex should match <code>"Aaaaaaaaaaaaaaaa"</code>.
testString: assert(result[0] === 'Aaaaaaaaaaaaaaaa', 'Your regex should match <code>"Aaaaaaaaaaaaaaaa"</code>.');
- text: 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), 'Your regex should not match any characters in <code>"He made a fair move. Screaming about it can't help you."</code>');
- text: 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), 'Your regex should not match any characters in <code>"Let him have it. It's not wise to upset a Wookiee."</code>');
Challenge Seed
let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /change/; // Change this line
let result = chewieQuote.match(chewieRegex);
Solution
// solution required