Well, why it is not working it should be obvious to you: almost the only thing you’ve changed ( flags apart) was the problem - o won’t match O.
Why it is working elsewhere, that would be an interesting question
Just for anyone reading this solution. You have to add the \s tag to include whitespace at the end of your upper and lower number specification /Oh{3,6}\sno/ for it to work. The code presented as solution does not work!
The reason you have to put a capital O is that the test cases have capital O’s, You could alternatively write /oh{3,6}\sno/i.
I think the problem is with the g tag. But I have not yet figured out why this is causing an error. It works fine with g tag here for example.
This is true ^^ That expression will match any statement into which it can find at least 3h and 6h at most. If you have a word with 7h that word contains a ‘cluster’ with 6h and this is the match^^
This regex will not match the 7h word because now the 3/6 h match must be followed by a space, not by another h^^
I think the problem is with the g tag. But I have not yet figured out why this is causing an error
I think that the problem could have something to do with the order of the tests, but I’m not sure about that.
Here is the reference that arouse my doubts: MDN - RegExp-prototype.test
if you want to understand it more pricise ,use it with match wich retuns an array to see that we put a range like this {3,6} the match method takes only the letters that are between that range so that in test it does not seem very clear .
Hello, after many attempts i later got it. The White space in the ohStr value is what you have to add after the curly braces instead of “no”. So your syntax will go like /Oh{3,6} /; take note of the white space.
This passed in every other regex online but not in here.
It was complaining about not matching “Ohhhh” and “Ohhhhhh” which is not the case!
It worked after I removed the “g” flag.
Please, someone fix this question
I was getting extremely hung up on the same idea that /h{3,6}/ should work.
I had to think this through for a minute. Approaching it asking myself what the .test() method would return on a string with more than 6 ‘h’ helped me see why it is not the full solution.
However, the instructions and requirements for this challenge are quite vague and ambiguous to me.
Yep it’s a little bit confusing that this works on https://regex101.com/
Oh{3,6}\sno/g
But it doesn’t here. But if you remove the g flag, it works. Strange. But it seems that they don’t care. A lot of the regex questions here are not very clear.