I’m trying to match all content between <!-- and -->
My php code:
<?php
$html = <<< HTML
<!-- content
content content
content -->
<!-- dd dsd sdsd s -->
<!-- dsajda2i -->
HTML;
preg_match_all('#<!-- (.*) -->#si',$html,$out,PREG_SET_ORDER);
print_r($out);
?>
but it doesn’t match it properly.
OBS: i can have any character inside <!-- here any characters -->.
can someone help me please?
You should use
(.*?)instead of just(.*). The default “greedy” behavior of the regex engine would otherwise yield unexpected results.