允许非 ASCII 字符的(类似 twitter 的)主题标签的正则表达式 [英] Regex for a (twitter-like) hashtag that allows non-ASCII characters
问题描述
我想要一个正则表达式来匹配 twitter 中的一个简单的主题标签(例如#someword).我还希望它能够识别非标准字符(如西班牙语、希伯来语或中文中的字符).
I want a regex to match a simple hashtag like that in twitter (e.g. #someword). I want it also to recognize non standard characters (like those in Spanish, Hebrew or Chinese).
这是我最初的正则表达式:(^|s|)(#(w+))
--> 但它不能识别非标准字符.
然后,我尝试使用 XRegExp.js,虽然有效,但运行速度太慢.
This was my initial regex: (^|s|)(#(w+))
--> but it doesn't recognize non standard characters.
Then, I tried using XRegExp.js, which worked, but ran too slowly.
有什么关于如何去做的建议吗?
Any suggestions for how to do it?
推荐答案
最终我发现了这个:twitter-text.js 有用的链接,基本上就是 twitter 解决这个问题的方法.
Eventually I found this: twitter-text.js useful link, which is basically how twitter solve this problem.
这篇关于允许非 ASCII 字符的(类似 twitter 的)主题标签的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!