Match Characters that Occur Zero or More Times -- help

Match Characters that Occur Zero or More Times -- help
0.0 0

#1

Tell us what’s happening:

In the instructions example below why does the gPhrase.match(goRexex); returns [“g”]? Shouldn’t it return null cause the check was for “go”.

let soccerWord = “gooooooooal!”;
let gPhrase = “gut feeling”;
let oPhrase = “over the moon”;
let goRegex = /go*/;
soccerWord.match(goRegex); // Returns [“goooooooo”]
gPhrase.match(goRegex); // Returns [“g”]
oPhrase.match(goRegex); // Returns null

Your code so far


let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /Aa*/;
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/66.0.3359.181 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

In the instructions example below why does the gPhrase.match(goRexex); returns [“g”]?

It’s go *
The asterisk means 0 or more, hence it will match g, go, goo, etc^^


#3

hello dear ,me too at the beginnig that was for me not abvious , but the answer is right .
let goRegex = /go*/; means match every(g) followed by zero number of the letter (o) or more ,that’s why the answer was g , so g is accepted because it is followed by zero letter .