fork(9) download
  1. <?php
  2.  
  3. $input = "<html><head>{{HEAD}} text {{head}} don't match anything</head><body>
  4. s{s ds
  5. ds{{Monday}}ds
  6. s
  7. dsd}{s
  8. ds{{Tuesday}}dsd sdsd
  9. d{}sd}s
  10. {{Wed}}
  11.  
  12. }
  13. {
  14. fdsa dsafasd
  15. </body>
  16.  
  17. {{DontCapture}}";
  18. preg_match_all("/<body>|(?!^)\G(.*?){{(?<DAY>.*?)}}(?=.*<\/body>)/s", $input, $matches, PREG_SET_ORDER);
  19.  
  20. foreach ($matches as $match) {
  21. if (isset($match['DAY'])) {
  22. echo $match['DAY'];
  23. }
  24. }
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
MondayTuesdayWed