3v4l.org

run code in 500+ 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:
100.02 ms | 1247 KiB | 5 Q