Can I ask though - what is it that the g flag does that makes having it at the end of that expression such a bad thing? (I had the same code til I saw this post.)
Thanks - read through that and still pretty clueless (a depressing pattern that’s developed between me and stackoverflow). lastIndex hasn’t been mentioned thus far in the FCC Regex tutorials… What is it, and why does it matter?
From what I understand, adding g at the end means that the test/match/whatever will return all the instances of the regex it finds. so if there’s one match, it will return that. If there are 1500 matches, it returns all 1500. This doesn’t seem like the kind of thing that should mess me up in this scenario?