The difference between "*" and "+" when it's in the Match case?

I tried to change the “*” to “+” , it turns out that the first result doesn’t change while the second changes, anybody can tell me the difference between them, thanks!

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/100.0.4896.88 Safari/537.36

Challenge: Match Characters that Occur Zero or More Times

Link to the challenge:

* looks for zero or more matches, + looks for one or more matches. So if you used /a*A+a+/ you would still match Aaaaa because even though it starts with a lowercase a, it ignores it and moves on to A which it needs to find at least one of, then a which it would also need to find one of.

If you don’t already i recommend using to mess around and learn about regular expressions.

1 Like

Thanks so much, I’ve already know the difference between the “*” and “+”, and the website you provided is wonderful, have a good day!

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