I’m having trouble with regular expressions of Javascript section and I came across this lesson:
I have googled a bit about what this “*” do and I still can’t get why it returns “g” on the second string (there are actually two "g"s on that string). And why the third string returns “null”, when yes, “g” occurs zero times, but “o” does occur… and as I see is not looking for the string “go” nor for “g” alone, but for both characters separately, right? Otherwise why it returns “gooooooooo” in the first one?
Also, If I run this code on Visual Studio and check the console, it actually returns an array…
I used console.log() cause without that, it was not returning anything at all on the console…
Thanks in advance to anyone who is wiling to help!
Hi! Thank u for your time answering!
Got a question regarding it. If the regex matches “a g followed by 0 or more o” as you say, why it returns “g” alone on the second string? There’s no g followed by o there.