Specify Upper and Lower Number of Matches

Tell us what’s happening:
Problem to pass this test:
Your regex should not match “Ohhhhhhh no”

Your code so far

let ohStr = "Ohhh no";
let ohRegex = /h{3,6}/; // 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/66.0.3359.181 Safari/537.36.

Link to the challenge:

The regex you have, /h{3,6}/ only targets strings that have 3-6 h’s and nothing else. But the strings you are trying to match are like "Ohhh no" and "Ohhhhh no" - you need to account for the other letters.

1 Like

Thank you for the help, I didn’t realize that it was missing the rest of the string.

thanks for help but I am not able to do that can you help me the code please

I’m sorry, but your question isn’t specific enough to give a good answer. Hopefully this demonstration helps:

let myRegex = /ab{2,5}c/

// false
// true
// true
// false

It requires an ‘a’, followed by 2-5 'b’s and a ‘c’.

1 Like

No matter if i do /h{3,5} no/i or /h{3,5} no/i or /h{3,3}/i or /h{3,4}/i only the last condition does not pass. Its almost like its just not checking.

First of all, can get rid of the i - it should be case sensitive.

Your first one is close, but you didn’t account for the “O” at the beginning and you didn’t read the instructions about the number to match closely enough:

Change the regex ohRegex to match only 3 to 6 letter h’s in the word “Oh no”.

Even then i tried /O{3,6} no/ and it doesn’t match anything.

Right, because you removed the “h”. The {3,6} refers to the character that precedes it. You are checking if there are 3-6 “O”. “O” should be at the beginning and “h” is what you are looking for for repeats. For example:


would match “Yees” and “Yeees” but not “Yes” or “Yeeees”.


The above doesn’t work either. I used a regex tester for all the test, and it definitely passes. I had the same problem with the username challenge, and It doesn’t match strings that it should match.

I think the “g” is screwing it up. In theory it should work but it is not needed here and it is screwing up the test.

Hi, I don’t understand why you need \sno I only use \s

Hi, this one worked for me:
let ohRegex = /oh{3,6}\s/i;

1 Like

It works for me too, thanks

For me the description for this task should be change.
Both description:

Change the regex ohRegex to match only 3 to 6 letter h’s in the word “Oh no”.


Article with hint

tells about matching only “h” and not the whole word.

yeah, I don’t get the last test case: "Your regex should not match "Ohhhhhhh no""

what is the point in the upper bounds of {3,6} if it will also match more than 6? that doesn’t seem to make sense

it’s to show the 7 ‘h’ case also contains 6 ‘h’