<?php
$content = "这些人都在呢? 怎么样啊 @小雨 看看天上的飞机 @develop_p ...";
if (false !== strpos($content, '@')) {
if (preg_match_all('~\@([\w\d\_\-\x7f-\xff]+)(?:[\r\n\t\s ]+|[\xa1\xa1]+|[\xa3\xac]|[\xef\xbc\x8c]|[\,\.\;\[\#])~', $content, $match)) {
if (is_array($match[1]) && count($match[1])) {
foreach ($match[1] as $k => $v) {
$v = trim($v);
if (' ' == substr($v, -2)) {
$v = substr($v, 0, -2);
}
if ($v && strlen($v) < 16) {
$match[1][$k] = $v;
}
}
}
}
}
?>
转载于:https://my.oschina.net/tianranqi/blog/176190