Specify Exact Number of Matches2

Tell us what’s happening:

Not passing my code for some unknown reason…

Your code so far


let timStr = "Timmmmber";
let timRegex = /tim{4}ber/; // Change this line
let result = timRegex.test(timStr);

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.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/specify-exact-number-of-matches

JavaScript regular expression are case-sensitive, so there is a difference between t and T.

Please mind the case-sensitive flag, t is not T, unless you go for i flag.

My original solution (which was incorrect) was /m{4}[^m]/, which worked for all of the tests but the Timber with 30 m’s. It wasn’t until I gave my code the Ti in the beginning that I got the checkmark. Can anyone explain why?

Because Timber with 30 m has mmmm at the end, in front of the ber,
and this does match find 4 m and not an m at the following index.