Regular Expressions - Match Characters that Occur Zero or More Times

Tell us what’s happening:
My code passed for 3 first tests, but failed for 2 last tests.
I have check it on a tool called RegExr then I see that my code didn’t match any character in the 2 below string (2 last tests).
Is any solution for this?

  • Passed:Your regex chewieRegex should use the * character to match zero or more a characters.

  • Passed:Your regex should match the string A in chewieQuote.

  • Passed:Your regex should match the string Aaaaaaaaaaaaaaaa in chewieQuote.

  • Passed:Your regex chewieRegex should match 16 characters in chewieQuote.

  • Failed:Your regex should not match any characters in the string He made a fair move. Screaming about it can't help you.

  • Failed:Your regex should not match any characters in the string Let him have it. It's not wise to upset a Wookiee.

Your code so far

// Only change code below this line
let chewieRegex = /a*(?=[ar])/gi; // 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/112.0.0.0 Safari/537.36

Challenge: Regular Expressions - Match Characters that Occur Zero or More Times

Link to the challenge:

Chewie only speaks words that start with a

Aaaaaaaaaaaaaaaarrrgh!

Oh, I realized that I just make it complicated.
I just need /Aa*/, no need for gi

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