Skip to content

Commit

Permalink
Merge pull request #67 from zhuchunshu/dev
Browse files Browse the repository at this point in the history
更新:优化艾特解析
  • Loading branch information
zhuchunshu committed Sep 18, 2023
2 parents 89ca025 + 3eaff7f commit 4fc39c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/Plugins/Core/helpers.php
Expand Up @@ -189,15 +189,15 @@ function format_date($time)
*/
function get_all_at(string $content): array
{
preg_match_all('/@([^\p{P}\p{S}\s]+)/u', replace_all_at_space($content), $arr);
preg_match_all('/@(\w+)(?=[^\w@]|$)/u', $content, $arr);
return $arr[1];
}
}

if (! function_exists('replace_all_at_space')) {
function replace_all_at_space(string $content): string
{
$pattern = '/@([^\p{P}\p{S}\s]+)(?=[^ <\/p>]+)/u';
$pattern = '/@(\w+)(?=\s|$)/u';
return preg_replace_callback($pattern, static function ($match) {
return $match[0];
}, $content);
Expand All @@ -215,10 +215,10 @@ function remove_all_p_space(string $content): string
function replace_all_at(string $content): string
{
//$pattern = "/\\$\\[(.*?)]/u";
$pattern = '/@([^\p{P}\p{S}\s]+)(?=[^ ]+)/u';
$pattern = '/@(\w+)(?=[^\w@]|$)/u';
$content = replace_all_at_space($content);
return remove_all_p_space(preg_replace_callback($pattern, static function ($match) {
// var_dump($match[1]);
var_dump($match);
return (new \App\Plugins\Core\src\Lib\TextParsing())->at($match[1]);
}, $content));
}
Expand Down

0 comments on commit 4fc39c4

Please sign in to comment.