fork(1) download
  1. <?php
  2.  
  3. $string = '<br/> <br>
  4.  
  5. <!--
  6. this is a comment
  7.  
  8. -->
  9. <br/> <br/>';
  10.  
  11. $new_string = preg_replace('#(?(?!<!--.*?-->)(?: {2,}|[\r\n\t]+)|(<!--.*?-->))#s', '$1', $string);
  12. echo $new_string;
  13. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
<br/><br><!--
this   is a comment

--><br/><br/>