I am stucked in something 😅

Umm Guys can anyone tell me why do I need to insert \s and the ignorance case{i} in ohRegex to pass this

Your code so far

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

Challenge: Specify Upper and Lower Number of Matches

Link to the challenge:

Hi @meetb !

The string has a space so you need to test for that. That is why you need to include the \s.

You also need to include the i flag because you have not chosen to capitalize the O in the beginning.

You will notice if you did capitalize the O here

then you wouldn’t actually need the i flag for this test. It would still pass.
you still need to acknowledge the space though.

Hope that makes sense.

You will notice if you did capitalize the O here then you wouldn’t actually need the i flag for this test. It would still pass.

why does it so? :thinking:

The i flag ignores casing.

With the i flag, you are telling the computer it doesn’t matter if the O is capitalized or not.

It is just testing for those letters in that order with the space.

But without the i flag, the computer is expected to test for a capital O because you haven’t specified otherwise.

All of these test cases have a capital O. If you want to ignore casing you need to specify that.

Make sense?


Thank you for helping me out Jessica Wilkins :kissing_heart:
Nicely explained :smiley:

1 Like

Jessica, one more question

to match only the letter (a) appearing between 3 and 5 times in the string , your regex would be /a{3,5}h/.

then does \w{3,6} match only letters appearing 3,6 times?? :zipper_mouth_face:

Are you changing the code to this?


If so, then the \w is the same as [a-zA-Z0-9_]
and it match the previous character 3-6 times.

Just like in the original code where you were testing for the letter ‘h’ 3-6 times.

no no its completely different than that challenge
but its confusing me :confused: :confused:

the main problem is in previous character actually

I guess I was confused by your question because you wrote this.

so i thought you were changing the original code.

Are you confused about the 3-6 times part or the \w part?


i am confused about what it actually does I mean I Don’t know :sweat_smile: :pensive: :worried:

Ohh ok.

I think what will help you is to test your regular expressions in a tool like Regex101

It will give you a break down of each component of the regular expression.

I would suggest using that for the rest of the section and the telephone project at the end of the javascript section.

Thank you so much for the suggested tool its nice :+1: :+1:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.