Match Characters that Occur Zero or More Times HELP

Match Characters that Occur Zero or More Times HELP
0

#1

what am i doing wrong here

Your code so far


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

Your browser information:

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

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


#2

a* matches nothing (0 or more)
try +


#3

remember that regextester I suggested you use to check? Here’s what you would have seen if you had tested your regex there:


#4

but then i am supposed to be matching in this lesson using *


#5

ok, so perhaps you need to match the first letter first exactly and then the rest of the a’s less specifically (with the star). Give it a try on regextester till you get the hang of it…


#6

i tried using gi flags,first three tests are passed but they said in the lesson that it does not need flags


#7

right, no flag is needed.

Think about how to match this exact string.
It start with an A…

Hope this is enough clue. And I really do suggest you try the regextester


#8

okay got it i used Aa to pass the test but it shouldnt have passed because the other test says do not match it with a line that has a in it and in the example code they extracted g even after putting in /go*/. i dont get it


#9

the reason /go*/ matches a ‘g’ or a ‘go’ or a ‘gooooo’ is because it actually looks for

one g and
zero or more o

so therefore
‘g’ has one g and zero o
‘go’ has one g and one o
‘goooo’ has one g and 4 os


#10

so if the condition of matching A is not met it stops checking for a* ?


#11

yes correct Aa* will only match ‘A’ or ‘Aa’ or ‘Aaa’ etc.


#12

For this problem, the ‘Aa’ also helps distinguish the difference between a single ‘a’ vs. ‘Aaaaaaargh’


#13

Another way to look at it, if I’m not stabbing a dead body.

To regular expressions: ‘A’ is a completely different from ‘a’. They are two distinct characters to search for.


#14

The question don’t allow to use regex flag so the simple answer is Aaaaaaaaaaaaaaaa*


#15

The instructions are unfortunately not very clear on the problem. I totally get the disconnect as I faced it as well.
To,possibly, help clarify the instructions…they want you to identify the capital “A” followed by the other ‘a’’ characters that follow.-not simply any "a"s in any random quote.
Maybe that could help.
I feel your pain though my friend.
Happy Coding!


#16

For everyone still wondering and going against the walls try doing the regex with Aaa …


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