Freecodecamp: Confusion in challenge "Regular Expressions: Match Characters that Occur Zero or More Times"

Created on 24 Jun 2018  路  6Comments  路  Source: freeCodeCamp/freeCodeCamp

Describe your problem and - if possible - how to reproduce it

Confusing requirements to pass challenge _Regular Expressions: Match Characters that Occur Zero or More Times_ (originally reported in this forum thread). The confusion results from lack of explanation in the challenge body, as well as the fact that an optimal answer wouldn't use the target syntax at all.

Add a Link to the page with the problem

_Regular Expressions: Match Characters that Occur Zero or More Times_

If possible, add a screenshot here

regex_challenge

Most helpful comment

hey @lionel-rowe i had also wanted to solve this challenge, after 2 days i have found the answer but it was too simple so we have messed up, i have confused because of this line in explanation

"Your regex does not need flags, and it should not match any of the other quotes." .

you wont believe what the solution is, it is so simple here it is: /Aa*/

in life also sometimes we think challenges are so harder to solve but it is not, answer is so simple like here.

All 6 comments

I can see what you mean. I do feel that after careful reading the problem statement isn't too confusing.

Someone could miss the fact that they're asking for both "upper and lower "a" characters in chewieQuote." If not, they might be tempted to use a bracket operator [aA].

Reading over the examples, this one let goRegex = /go*/; is very close to the actual solution.

Maybe a simple addition of wording would help:

"Create a regex chewieRegex that uses the * character to match all the upper and lower "a" characters in chewieQuote (both "A" and "a" characters). Your regex does not need flags, and it should not match any of the other quotes."

hey @lionel-rowe i had also wanted to solve this challenge, after 2 days i have found the answer but it was too simple so we have messed up, i have confused because of this line in explanation

"Your regex does not need flags, and it should not match any of the other quotes." .

you wont believe what the solution is, it is so simple here it is: /Aa*/

in life also sometimes we think challenges are so harder to solve but it is not, answer is so simple like here.

Here's why I think it's confusing:

  • The instruction says "match all the upper and lower "a" characters in chewieQuote. Your regex does not need flags, and it should not match any of the other quotes."
  • Really, the requirements are "match 2 or more consecutive "a" characters (case insensitive). It should not match when there is only 1 consecutive "a"."
  • The obvious solution for this would be /a{2,}/i, or perhaps /aa+/i. However, the challenge instead requires /aaa*/i. This fails to demonstrate how the * character is useful.

I realized that this is actually the wrong repo for this, so I'll open a new issue for it in /curriculum.

@lionel-rowe, you should re-open this issue here.

I agree that the instructions here are vague. It seems to me that the desired solutions is /Aa*/ so the instructions should probably read:

Create a regex, chewieRegex, that uses the * character to match the first uppercase "A" character followed by any number of lowercase "a" characters in chewieQuote. Your regex should not use any flags, and it should not match any of the other quotes.

A test should probably also be added that checks that no flags were used.

@MattYamamoto This challenge was updated recently but has not been deployed to production yet. You can take a look at the new version on our beta site.

If you feel the newer version is lacking, please open a separate issue, so it can be discussed further.

Thank you.

@RandellDawson the site is offline

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ar5had picture ar5had  路  3Comments

danielonodje picture danielonodje  路  3Comments

trashtalka3000 picture trashtalka3000  路  3Comments

ROWn1ne picture ROWn1ne  路  3Comments

SaintPeter picture SaintPeter  路  3Comments