I have JavaScript a code
var docBodyText = document.body.innerHTML;
var patt =/<!--:.+:-->/g;
patt.compile(patt);
var matchesB=docBodyText.match(patt)
and a HTML page
<body>
<span><b><!--:?time:--> <!--:?date:--></b></span>
<br />
<!--:?url:-->
</body>
When I execute the script it returns
["<!--:?time:--><!--:?date:-->","<!--:?url:-->"]
but I want
<!--:?time:--> and <!--:?date:-->
to be returned separately.
You are matching greedily. The
+by default means “1 or more times, but prefer as many as possible”. Add a?modifier after the+to make it match lazily: