php - 正则表达式日语单词无法逃脱
问题描述
解决方案
I would use the following regex for a hashtag:
#\S+
This will match a leading #
character, followed by one or more non whitespace characters (which would include Japanese Kanji).
Sample script:
$text = "#食への好きな人と繋かりたい #食への好きな人と繋がりたい #食べるの好きな人と繋がりたい";
echo $text . "\n";
$text = preg_replace("/#\S+/", "", $text);
echo $text;
The second echo
prints just two spaces (which were separating the three hashtags in the original input);
推荐阅读
- html - Firebase 错误:HTTP 错误:500,遇到内部错误
- python - 查找索引行和数据框中每一行之间的公共非空列
- bash - 在 Compute Engine 上完成启动脚本后保持屏幕活动
- html - 仅在内容溢出时添加边框
- dll - 从 .net 核心接收和发送消息到 mqseries 服务器
- android - 如何每 5 秒在 Firebase 上获取数据?
- android - 如何在不使用意图发送电子邮件的情况下打开电子邮件客户端?
- azure-logic-apps - Azure 逻辑应用程序继续运行并且不会停止
- mysql - CloudMySQL - SET GLOBAL sql_mode='ANSI'
- python - 如何将不同尺寸的 rgb 图像转换和组织成 CSV 文件?