Suppose I have a HTML comment like this:
<!--hello world-->
We can get the get the comment with this regex:
var expression = /<!--(.*)-->/g
Working example:
var expression = /<!--(.*)-->/g;
console.log(document.querySelector("div").innerHTML.match(expression)[0]);
<div>
<!--hello world-->
</div>
But if the comment is multi-line, like this:
<!--hello
world-->
Then the regex doesn't work.
var expression = /<!--(.*)-->/g;
console.log(document.querySelector("div").innerHTML.match(expression)[0]); // Will throw an error because it could not find any matches
<div>
<!--hello
world-->
</div>
How can I select the multi-line HTML comment?