Possible bug in Regex lesson?

Possible bug in Regex lesson?
0.0 0


In the lesson Regular Expressions: Match Characters that Occur Zero or More Times
URL: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times

the task is to come up with a regex that will match all upper and lower "a" characters using the * character.

I believe the regex that fulfills this condition is /a*/gi. When I use it, it doesn’t pass the test.

The feedback I get is:

Am I missing something?


The challenge is a little confusing. Really, the best regex to solve it would be /a{2,}/i, or perhaps /aa+/i (match 2 or more “a”s, case insensitive), but that fails the first condition (must use the * character).

It might help to think of the challenge this way:

  • It must match at least 2 “a”s.
  • After that, it can match 0 or more “a”s (this makes no difference to how the regex functions, but is necessary to pass the first test case).


I believe that usage of curly braces in regex is not covered yet before this challenge (if you go through the challenges by order of appearance in the curriculum).

If that is the case, I think the challenge description should be updated to make it more clear., or at least change the challenge’s content to match what it teaches…


To be clear, the /a{2,}/i solution isn’t how to pass the challenge, although a valid solution can include curly-brace notation. That’s just what I’d consider to be the best/clearest solution if you needed a regex to do this in production code (maybe for some sort of wookie-themed natural language processing app? :joy:)

The code and copy for the fCC challenges is all open source and written by volunteers, and contributions are welcome. I agree it’s somewhat confusing, so I’m opening an issue on the GitHub repo now.


Yes I understood that, all I’m saying is that the challenge, it’s description or it’s solution test need to be rewritten.

I tried to clone the FCC repo and the curriculum repo to fix a different bug, but ran into problems.
There is a known bug happening with running FCC locally, and I understood from other people in the Contributors’ Gitters chat room that it’s being addressed.

I also tried to commit a change and ran into problems with that…