3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'hello @tag1 111 world @tag2 @tag3 222 333'; if (preg_match('~(?<!\S)(@\S+|\d+)(?:\s+(?1))*(?=\s*$)~', $str, $m)) { echo $m[0]; }

preferences:
51.96 ms | 1381 KiB | 5 Q