Regular Expressions - Find Characters with Lazy Matching

Tell us what’s happening:
Describe your issue in detail here.
This is just for my understanding. Can someone tell me why the ‘?’ has to be located where it is in this challenge?

Why does this: let myRegex = /<.?>/; work
and this: let myRegex = /<.
>?/; does not work

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/112.0.0.0 Safari/537.36

Challenge: Regular Expressions - Find Characters with Lazy Matching

Link to the challenge:

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