Matching Characters that Occur Zero or More Times

Tell us what’s happening:
Problem statement: Create a regex chewieRegex that uses the * character to match all the upper and lower"a" characters in chewieQuote. Your regex does not need flags, and it should not match any of the other quotes.

My code doesn’t work as it would fail in matching these two sentences -

  1. “He made a fair move. Screaming about it can’t help you.”
  2. “Let him have it. It’s not wise to upset a Wookiee.”

Your code so far

let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /a*/gi; // I wrote this code, but seems incorrect.
let result = chewieQuote.match(chewieRegex);

Your browser information:

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

Link to the challenge:



I think this regex is saying match anything with zero or more “a”'s hence it will return true for almost any string.
You need to make a regex that will only return true for the chewie quote (hint: it has upper and lower case “a”'s) and not the other ones with fewer “a”'s,

The challenge notes that you do not need to use any flags. So, if you had a string like this:


To get any amount of o’s in that string without using flags, you would do this:


That would match the first O and zero or more o’s thereafter.

Also, the hints tell you that your regex (for this challenge) should not match the other quotes. So the regex would have to be quite literal.

Rules are…
You can’t use the g and i flags so /a*/gi won’t work.
You must use the * - you’re doing that.


Wookie calls have lots of a’s and start with an A.
You need to avoid the word a
You need to avoid words that have an a, like have, that aren’t wookie calls

So you are looking to match Aa or aa followed by zero or more additional a characters
you are looking to match A or a and an a followed by zero or more a’s

Even passing solutions might fail on Aardvaark. You’re better than that though.

If you need a better regex playground try to test possible solutions.

Many thanks Sir, I took a cue from your post and it worked :slight_smile:

Thank you Sir for providing the regex link. Very nice website to practice. Many thanks!!

1 Like

Hi Sir, you are right, I mis-interpreted it. Thank you so much :slight_smile:

Miss, not Sir. You’re welcome :slight_smile: