Solution code does not pass test run

Tell us what’s happening:
The code I wrote matches the code provided in the solution, however it still does not pass the test run.
Any suggestions?

Your code so far


// Only change code below this line
let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /[Aa*]/; // Change this line
// Only change code above this line

let result = chewieQuote.match(chewieRegex);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36

Challenge: Match Characters that Occur Zero or More Times

Link to the challenge:

Look closely at the example goRegex pattern in the lesson again. Your solution should basically mimic that.

The square brackets you have added create a character class which changes the nature of the match and is why your regex is failing. One thing they do is remove the importance of order, so while /Aa/ requires that “A” come before “a”, /[Aa]/ does not require this. Also, the meaning of * changes in a character class and literally means match the character * not “zero or more times”. Finally, the character class represents just one character in the string, so [Aa*] means "find one character in the string that is either an A or a or *".

1 Like

Understood. Thanks for detailed explanation.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.