Match Characters that Occur Zero or More Times, error but all right

Tell us what’s happening:

Good evening everyone! JS / RegExp for some reason, one job swears, although the result is correct.

Your code so far

let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
//let chewieQuote = "He made a fair move. Screaming about it can't help you.";
//let chewieQuote = "Let him have it. It's not wise to upset a Wookiee.";
let chewieRegex = /a*/i; // Change this line
let result = chewieQuote.match(chewieRegex);
console.log(result[0].length + ' ' + result);

result = "He made a fair move. Screaming about it can't help you.".match(chewieRegex);
console.log(result[0].length + ' ' + result);

result = "Let him have it. It's not wise to upset a Wookiee.".match(chewieRegex);
console.log(result[0].length + ' ' + result);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:


Your regex does not need flags, and it should not match any of the other quotes.

let chewieRegex = /a*/i; // Change this line

In your code snippet you use the flag, but you should not. And additionally your current regexp is matching the two other cases, but it should not. :slight_smile:

Therefore, you have to replace the current /a*/i to only /Aa*/.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

1 Like

You right, but without /i solved only examples from lesson, it not work for something as it “aAaaaaA”.
And yes, about flags written, but it not be focused.

that’s true, but if you write /a*/ you are just matching everything, even strings where there is not an a
instead you need to specifically match that string, chewieQuote without matching the others

Thanks, but i try write function then send nothing for four/five test.
But it solved more easy. :slight_smile:

Got you. Will take this into account next time.