How PHP uses regular expressions to get topic and object names in Weibo
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!