fork(1) download
  1. <?php
  2.  
  3. $pattern = '/(\[caption\sid="\d+"\].*\[\/caption])/';
  4.  
  5. $string = '<p>Something outside caption[caption id="456"]Content[/caption]</p>';
  6.  
  7. $captionRemoved = preg_replace($pattern, '', $string);
  8.  
  9. header('Content-type: text/plain');
  10. echo $captionRemoved;
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
<p>Something outside caption</p>