Regular Expressions - Match Characters that Occur Zero or More Times

Tell us what’s happening:
Describe your issue in detail here.
Hello freeCodeCampers !
I’m doing this exercise but what make me wonder is the example of the exercise on this line let oPhrase = "over the moon"; it shows null even when i make it search for global matches g, Any assistance would be very appreciated.
Your code so far

// // Only change code below this line
// let chewieRegex = /change/; // Change this line
// // Only change code above this line

// let result = chewieQuote.match(chewieRegex);

let soccerWord = "gooooooooal!";
let gPhrase = "gut feeling";
let oPhrase = "over the moon";
let goRegex = /go*/gi;
console.log(soccerWord.match(goRegex))
console.log(gPhrase.match(goRegex))
console.log(oPhrase.match(goRegex)) 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.63

Challenge: Regular Expressions - Match Characters that Occur Zero or More Times

Link to the challenge:

You’re talking basically about this case, right?

let oPhrase = "over the moon";
let goRegex = /go*/gi;
console.log(oPhrase.match(goRegex)) 

Wouldn’t we expect it to be null? Are there any cases of a “g” followed by 0 or more "o"s in that string?

1 Like

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