如何搜索关键字和主题标签或符号? [英] How to search keyword and hashtags or symbol?

查看:42
本文介绍了如何搜索关键字和主题标签或符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入框,用户可以在其中输入关键字或#tag 字词,单击搜索按钮后,它会找到包含该关键字或#tags 的字段.
1. 我试过 %like% 它有效,但如果只搜索 #m 它会给我所有带有 m 字母的单词.
2.我也试过正则表达式像这样
WHERE notes REGEXP '[[:<:]]{$f['activityId']}[[:>:]]'
但它不适用于#tag 或其他符号.
3.我也使用全文搜索,但它不适用于符号
我从这里参考全文,我不想重新编译我的 mysql.
全文搜索

I have a input box in which user can enter either keyword or #tag word and after click on search button it will find that field which have that keyword or #tags.
1. I tried %like% it worked but if search only for #m it is giving me all words which have m letter.
2. I tried regular expression also like this
WHERE notes REGEXP '[[:<:]]{$f['activityId']}[[:>:]]'
but it is not working for #tag or other symbol.
3. I use also full text search but it is not working for symbol
i refer from here for full text , and i don't want to recompile my mysql.
Full text search

有没有办法用#tag和符号搜索关键字
像:@amitesh,#amitesh,amitesh 等

Is there any way to search key word with #tag and with symbol
Like : @amitesh,#amitesh,amitesh etc.

推荐答案

mysql> SELECT 'foo #amitesh bar' REGEXP '([[:<:]]|#|@)amitesh[[:>:]]';
+---------------------------------------------------------+
| 'foo #amitesh bar' REGEXP '([[:<:]]|#|@)amitesh[[:>:]]' |
+---------------------------------------------------------+
|                                                       1 |
+---------------------------------------------------------+

我认为 # 和单词 start ([[:<:]]) 不能很好地配合使用.因此,要查找 @amitesh,#amitesh,amitesh 中的任何一个,我决定使用word start OR # OR @".

I think the # and the word start ([[:<:]]) are not playing well together. So, to look for any of @amitesh,#amitesh,amitesh, I decided on "word start OR # OR @".

这篇关于如何搜索关键字和主题标签或符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆