3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = ' #chapter 1: title 1 content chapter 1 line 1 content chapter 1 line 2 content chapter 1 line 3 content chapter 1 line 4 #chapter 2: title 2 content chapter 2 line 1 '; preg_match_all('/#Chapter\h+\d+:\h+title\h+\d+\K(?:\R(?!#chapter).*)*/i',$str, $match); print_r($match[0]);

preferences:
25.79 ms | 405 KiB | 5 Q