fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $file_content = <<<FILE
  6. WEBVTT
  7.  
  8. 00:00:00.300 --> 00:00:01.000
  9. line1
  10.  
  11. line2
  12. line3
  13.  
  14. 00:00:01.000 --> 00:00:02.800
  15. line1
  16.  
  17. 00:00:02.800 --> 00:00:04.800
  18. line1
  19. line2
  20.  
  21.  
  22. line3
  23. FILE;
  24. $regexp = '/(\R)(\R*)(\D|!(\d{2}:\d{2}:\d{2}\.\d{3}\s-->\s\d{2}:\d{2}:\d{2}\.\d{3}))/';
  25. $content = preg_replace($regexp, "\n$3", $file_content);
  26. echo $content;
  27.  
  28.  
  29.  
Success #stdin #stdout 0.02s 23992KB
stdin
Standard input is empty
stdout
WEBVTT

00:00:00.300 --> 00:00:01.000
line1
line2
line3

00:00:01.000 --> 00:00:02.800
line1

00:00:02.800 --> 00:00:04.800
line1
line2
line3