let soccerWord = "gooooooooal!";
let gPhrase = "gut feeling";
let oPhrase = "over the moon";
let goRegex = /go*/;
soccerWord.match(goRegex);
gPhrase.match(goRegex);
oPhrase.match(goRegex);
In order, the three match calls would return the values ["goooooooo"] , ["g"] , and null .
…why does gPhrase only return the first ‘g’ of ‘gut feeling’ and not the second one please?
Sorry i misunderstood your question. It’s because the regex doesn’t have global flags, if you want the program to return each time the regex matches you’ll have to do this