Feedback for the Javascrip Regular expression

Feedback for the Javascrip Regular expression
0

Where can I give feedback to the staff of freecodecamp?
IDK if I’m posting in the right place but I have this:

This exercise:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/find-characters-with-lazy-matching

Can also be solve with this regex: -> /<h1>/

I hope this feedback helps

do you want to report a bug?

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

Or do you want to suggest a different solution for the guide?

Any ideas on why this (my) code doesn’t pass:

let text = "<h1>Winter is coming</h1>";
let myRegex = /<h1>/; // Change this line
let result = text.match(myRegex);

Solution code is given as:

let text = "<h1>Winter is coming</h1>";
let myRegex = /<.*?>/; // Change this line
let result = text.match(myRegex);

In both cases
console.log(result):


[ '<h1>',
  index: 0,
  input: '<h1>Winter is coming</h1>',
  groups: undefined ]

thanks

The test output tells you why.

  1. You are not using the ? character (lazy matching).

  2. You have the string h1 in the regex.

Where is the test output? Why do we need to use the ? character? Why can’t we have string h1 in the regex?

  1. Below the three buttons on the left and in the console below the code editor.

  2. Because that is the point of the challenge, to teach you about making quantifieres “non-greedy”.

  3. Because it was likely deemed “cheating” to use a specific match for h1. That defeats the purpose of using a quantifier. What if you need to match some other element like an <h2> or a <section> element or whatever else, you would have to hardcode the regex for each of the elements.

OK, thanks, I see the three buttons. I often find the instructions confusing, and I didn’t realize that the three buttons were part of the instructions.