Specify Upper and Lower Number of Matches -- Regex works at regExr?

Tell us what’s happening:
Anyone else having trouble with this one? I plug the regex into regExr and all the tests work there so I think that there is something wrong with the test suite itself? (there is a space between the } and the / btw…if you’re like me it’s hard to see even with glasses on :wink:

specific response is:

// running test
Your regex should match “Ohhhh no”
Your regex should match “Ohhhhhh no”
// tests completed

but as I said, when I plug the regEx into regExer and put those test strings in, they are matched there.



Your code so far

let ohStr = "Ohhh no";
let ohRegex = /Oh{3,6} /g; // Change this line
let result = ohRegex.test(ohStr);

Your browser information:

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

Link to the challenge:

remove the g at the end of your regex, and try it again.
g supposed to change the state/index of regex for each call.

check this thread also.

keep goin on great work, happy programming.

1 Like

Doh! That was it. Thank you! The confusion comes in that regExr seems to add the g at the end automatically–so I couldn’t figure out why the same regex would work there but not here. After reading the other thread you mention, I remember stumbling across this in Java too–a long time ago. Live and learn :).