Regular Expressions: Specify Upper and Lower Number of Matches

Regular Expressions: Specify Upper and Lower Number of Matches
0

#1

Hi Campers,

I’m rattling through Regular expressions, but can’t quite work out why I’m failing the final test here:

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/specify-upper-and-lower-number-of-matches

My code so far:

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

Any pointers most welcome.

Thanks in advance.

Gerald


#2

You are matching on hs, but the instructions want you to be dealing specifically with the words “Oh no” with 3-6 hs.


Regex Javascript Issue
#3

Penny’s dropped! Many thx.


#4

I’m actually still confused…


#5

You specifically need a regex for “Oh no” with three to six hs. If all that is in your regex pattern is h{3, 6} then you will match any three to six hs.