继续求教正则表达式问题
$str = "昨天 @测试 hiaaaa dd@测试 反反复复";
$reg = "/([^@]+(?=\s))/";
$arr = preg_split($reg,$str,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
print_r($arr);
Array ( [0] => 昨天 [1] => @ [2] => 测试 [3] => hiaaaa [4] => dd@ [5] => 测试 [6] => 反反复复 )
Array ( [0] => 昨天 @ [1] => 测试 [2] => hiaaaa dd@ [3] => 测试 [4] => 反反复复 )
$str = "昨天 @测试 hiaaaa dd@测试 反反复复@好友2";
$str = "昨天 @测试 hiaaaa dd@测试 反反复复@好友2";Array
$reg = "/(@\S+)/";
$arr = preg_split($reg,$str,-1,PREG_SPLIT_DELIM_CAPTURE
[解决办法]
PREG_SPLIT_NO_EMPTY );
print_r($arr);