fork download
  1. <?php
  2. $str = <<<STR
  3. StackOverflow<br>
  4. <br>
  5. <br>
  6. <br>
  7. <br>
  8. is
  9. <br>
  10. <br>
  11. <br>
  12. <br>
  13. a
  14. <br>
  15. community.
  16. STR;
  17. echo preg_replace("!(<br(?: /)?>\s){2,}!s", "<br />\n<br />\n", $str);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
StackOverflow<br />
<br />
is
<br />
<br />
a
<br>
community.