Basically youâre finding the shortest route from â<h1â to the next â>â. Without the question mark, it would find the longest route to the next â>â which would return the whole variable.
Reading âRemember the wildcard . in a regular expression matches any character.â
I think the correct solution should keep the wildcard . so I tried with myRegex = /<.*?>/;
and pass the test
âGreat is the confusion under the sky. The situation is excellentâ
The most efficient way to match this is /<.*?>/ or /<.+?>/ although this will work but it will only match only opening tag <h1> and not </h1> accompany it with g to get all the matches.