Please help me understand this Regex question

Tell us what’s happening:
Hello,
Will someone explain what is happening behind the scene?
Description says Lazy and Greedy…I got it but I wish to understand the behind-the-scene concept.

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/88.0.4324.146 Safari/537.36.

Challenge: Find Characters with Lazy Matching

Link to the challenge:

Hi @roc_tanweer !

I edited your title for the post to remove the link. Avoid posting links in the title since we can’t click on them.

If you want to know what each part of the regex means then I would suggest using the Regex101 tool.

It acts like a debugger for regular expressions and gives detailed explanations for each character.

1 Like