Tell us what’s happening:
I have no idea what this challenge wants me to do. And also, why does /t[a-z]*?i/return only ti? What did it put between t and i?
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/85.0.4183.121 Safari/537.36.
You’re supposed to be examining the difference between greedy matches and lazy matches. In the examples with the challenge, /t[a-z]*i/ is greedy and will match as much of titanic as possible, namely titani. The regular expression is looking for a lowercase t, followed by zero to as many lowercase letter characters from a to z as possible (greedy), and then an i. Change this to a lazy regular expression by adding ? (like /t[a-z]*?i/), and it will match a lowercase t, followed by zero to as few lowercase letter characters from a to z as possible (lazy), and then an i, namely ti.
The challenge wants you to use a lazy regular expression to match the <h1> tag, without including the Winter is coming</h1> and without using h1 in the regular expression. The greedy regular expression /<.*>/ given in the challenge will match <h1>Winter is coming</h1>, or zero to as many characters as possible between a < and a > inclusive.