Regular Expressions: Match Characters that Occur Zero or More Times

Regular Expressions: Match Characters that Occur Zero or More Times
0

Tell us what’s happening:

Can’t solve this. I have tried everything I can and still can’t pass.
see the following solutions that I have tried:

Your code so far
let chewieQuote = “Aaaaaaaaaaaaaaaarrrgh!”;
let chewieRegex = /A-a*/ig; // Change this line
let result = chewieQuote.match(chewieRegex);

let chewieRegex = /A*/ig; // Change this line

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

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

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

and so on. Nothing works. What am I doing wrong?


let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /A-a*/i; // Change this line
let result = chewieQuote.match(chewieRegex);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times

Hi

What test are you trying to complete?

If you’re trying to match to whole quote, you need to also include the other characters as well.

Well, if you see this, just remember A and a are two different things for regex

technically this string only has one A and many a’s

hint hint

3 Likes

Having the same problem . Can someone Explain what the problem actually intended us to do?

Try this.

let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /aaa*/i; // Change this line
let result = chewieQuote.match(chewieRegex);

It matches aa with zero or more a’s followed by. Ex: aa, aaa, aaaaa etc
or

let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /aa+/i; // Change this line
let result = chewieQuote.match(chewieRegex);

last one doesn’t pass the test but it is also correct. Only reason is not using * character.

This worked for me. The instructions said not to use flags.

let chewieQuote = “Aaaaaaaaaaaaaaaarrrgh!”;
let chewieRegex = /Aaa*/; // Change this line
let result = chewieQuote.match(chewieRegex);

let chewieRegex = /Aa*/ ; change this line
also worked for me

Thanks

‘let chewieRegex = /aaa*/i;’

It works.