<?php $str = 'hello @tag1 111 world @tag2 @tag3 222 333'; if (preg_match('~(?<!\S)(@\S+|\d+)(?:\s+(?1))*(?=\s*$)~', $str, $m)) { echo $m[0]; }
You have javascript disabled. You will not be able to edit any code.