3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/(.*?)(\[\w{3}=\')(\w+\.\w+)(\'\])(.*?)(\[\w{3}=\')(\w+\.\w+).*/s'; $str = 'Hello, view this pdf [PDF=\'hello.pdf\'] and then view this PDF [PDF=\'goodmorning.pdf\']'; $subst = '$0'; $result = preg_replace($re, $subst, $str); echo $result;

preferences:
29.76 ms | 402 KiB | 5 Q