Freecodecamp: beta challenge issue https://beta.freecodecamp.com/en/challenges/regular-expressions/specify-exact-number-of-matches

Created on 29 Jun 2017  路  3Comments  路  Source: freeCodeCamp/freeCodeCamp

/m{4}/ does not solve it, which it should.

Most helpful comment

@koder3 thanks for the issue, but that regex shouldn't match. The last test it fails says your regex shouldn't match "Timber" with 30 m's in it. And /m{4}/ would match that, which it shouldn't. Additionally, the challenge requirement is to match the word "Timber" with a specific number of m's, not just the m's themselves. Closing as a non-issue. Happy coding!

All 3 comments

@koder3 thanks for the issue, but that regex shouldn't match. The last test it fails says your regex shouldn't match "Timber" with 30 m's in it. And /m{4}/ would match that, which it shouldn't. Additionally, the challenge requirement is to match the word "Timber" with a specific number of m's, not just the m's themselves. Closing as a non-issue. Happy coding!

This is the solution:
let timStr = "Timmmmber";
let timRegex = /Tim{4}ber/g;
let result = timRegex.test(timStr);

/Tim{4}ber/g doesn't actually work. And complains about the third test not being valid (testing the "Timmmmber" word)

I understand that the g flag is not strictly necessary. However, the test is misleading.

Another test not allowing TimmmmberTimmmmber would be okay to verify that the user is not providing the g flag

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichaelLeeHobbs picture MichaelLeeHobbs  路  3Comments

SaintPeter picture SaintPeter  路  3Comments

robwelan picture robwelan  路  3Comments

Tzahile picture Tzahile  路  3Comments

jurijuri picture jurijuri  路  3Comments