Why does the "?" have to come after the "*"?

Tell us what’s happening:
Describe your issue in detail here.
I have already completed the challenge, however, only after I found that adding the “?” before the “*” was not an acceptable answer. Why is this? I feel like when I go on to create a project and I accidentally put the “?” first, I might not know how to debug it as I don’t understand why it must come first.

Your code so far


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.39

Challenge: Find Characters with Lazy Matching

Link to the challenge:

? refers to lazy matching and should be before the closing character through which you want to match. Please read this post

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.