我如何使用Regex从sqlite获取数据? [英] How can i use Regex to get data from sqlite?
问题描述
我想在包含String的列中进行搜索,例如我将在她#Bday上与@Akki一起#dinner.我现在正在像这样进行搜索,但请注意. 而变量搜索的值类似于#dinner.谢谢.
I want to search in a column that containing String like "I will have #dinner with @Akki on her #Bday.I am searching now like this but it's note working. while the variable search having value like #dinner. Thank you.
selectionArgs = new String[] {"'"+search+"'"};
String qur="SELECT * FROM TODOS WHERE fullnote REGEXP";
Cursor c = db.rawQuery(qur,selectionArgs);
selectionArgs = new String[] {"'"+search+"'"};
String qur="SELECT * FROM TODOS WHERE fullnote REGEXP";
Cursor c = db.rawQuery(qur,selectionArgs);
推荐答案
经过长时间的研发,我指出我不能直接使用REGEXP.
然后我尝试了
Cursor c = db.rawQuery("SELECT * FROM TODOS WHERE tag LIKE '%"+search+"%' ",null);
After long R&D i came to point that i can not use REGEXP directly.
then i tried
Cursor c = db.rawQuery("SELECT * FROM TODOS WHERE tag LIKE '%"+search+"%' ",null);
,效果很好. 谢谢大家.
and it worked fine. Thanks everybody.
这篇关于我如何使用Regex从sqlite获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!