fork download
  1. <?php
  2.  
  3. $contents = get_contents();
  4. $block = 'A1';
  5.  
  6. $regexTemplate = '~^(?://Block %s)$.*?(?=^//Block)~msu';
  7. $regex = sprintf($regexTemplate, $block);
  8.  
  9. if (preg_match($regex, get_contents(), $matches)) {
  10. echo "Found:\n\n";
  11. echo $matches[0];
  12. } else {
  13. echo "Block $block not found\n";
  14. }
  15.  
  16.  
  17. function get_contents()
  18. {
  19. return <<<END
  20. //Block A1
  21. try {
  22. entoli1
  23. entoli2
  24. entoli3
  25. apotelesma
  26. } catch {
  27. error ktlp
  28. }
  29.  
  30. //Block A2
  31. try {
  32. entoli1
  33. entoli2
  34. entoli3
  35. apotelesma
  36. } catch {
  37. error ktlp
  38. }
  39.  
  40. return A1,A2
  41. END;
  42. }
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Found:

//Block A1
try { 
entoli1
entoli2
entoli3
apotelesma
} catch {
error ktlp
}