spi*_*der 6

此正则表达式将匹配HTML 注释

特别是:

<!-- matches literal string "<!--"
.    matches any character
*    is a quantifier, it means "0 or more" of the previous character
?    makes the regex non-greedy, so it matches as few times as possible
--> matches literal "-->"
Run Code Online (Sandbox Code Playgroud)

因此,您针对此文本的正则表达式:

blah <!-- first --> yaddahyaddah <!-- second --> other random words.
Run Code Online (Sandbox Code Playgroud)

只会匹配<!-- first -->.

http://regex101.com/r/gF7vX2/1

没有 ? 它将匹配第一次出现的<!--和最后一次之间的所有内容-->,换句话说,它将匹配:<!-- first --> yaddahyaddah <!-- second -->

http://regex101.com/r/fP4kA3/1