Get the App
SLTechnology News&Howtos  ›  Development  › 

How PHP uses regular expressions to get topic and object names in Weibo

Shulou Source: shulou.com Published: 2022-06-03 19:41:23 11月12日 Update

Editor to share with you how PHP uses regular expressions to get topics and object names in Weibo, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The specific implementation methods are as follows:

$post_content = "@ jb51 and @ twitter are working on using # regular expressions of # PHP# # to filter topic and object names"; $tag_pattern = "/ ([^\ # |.] +)\ # /"; preg_match_all ($tag_pattern, $post_content, $tagsarr); $tags = implode (',', $tagsarr [1]); $user_pattern = "/\ @ ([a-zA-z0-9 _] +) /" $post_content = preg_replace ($user_pattern,'@ ${1}', $post_content); $post_content = preg_replace ($tag_pattern,'# ${1} #', $post_content). That's all about "how PHP uses regular expressions to get topics and object names in Weibo". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Objects regularities expressions topics articles content not much most methods more knowledge industry information information channels channels references learning help research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn macOS Xiaomi MariaDB Linux