3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "This is a short sentence which should include all regex results"; echo preg_replace_callback( '~(\w{3})?(\w+)~', fn($m) => ($m[1] ? "+" : '') . "$m[0]*", $string );

preferences:
27.03 ms | 404 KiB | 5 Q