3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = <<<'AHA' abc [code lang='javascript'] var a = 2.5; [/code] bcd [code lang='php'] $this->foo(); [/code] cde [code lang='html'] <p clas = 'bar'><span>hello world</span></p> [/code] def AHA; $r='/((^|\[\/code\]).*?(\[code[^\]]*?\]|$))/s'; preg_match_all($r, $str, $a); print_r($a[0]);
based on 1B6AE
Output for 5.5.0 - 7.2.8
Array ( [0] => abc [code lang='javascript'] [1] => [/code] bcd [code lang='php'] [2] => [/code] cde [code lang='html'] [3] => [/code] def )