查询Android的SQLiteDatabase使用正则表达式 [英] Query Android's SQLiteDatabase using Regex

查看:819
本文介绍了查询Android的SQLiteDatabase使用正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用在Android程序取回从SQLiteDatabase条目<一个href=\"http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#query%28boolean,%20java.lang.String,%20java.lang.String%5B%5D,%20java.lang.String,%20java.lang.String%5B%5D,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29\">query使用选择参数的功能。我曾与使用SQLite的就像%通配符简单的模式匹配和成功。现在,我想用常规的前pressions做更复杂的模式匹配。

按照 SQLite的网站,对于REGEXP操作符的功能,它必须是用户定义的。有没有人有任何成功的Andr​​oid的SQLiteDatabase创建使用SQLite的定义的功能呢?或者有没有人发现了另一种方式,通过字符串在数据库中搜索时,使用常规的前pressions?


解决方案

由于这里 <描述 / p>


  

正则表达式运算符是正则表达式()用户功能的特殊语法。没有正则表达式()用户功能默认定义,所以使用REGEXP运算符通常会导致错误消息。如果在运行时被添加名为正则表达式一个应用程序定义SQL函数,该函数将被调用以执行REGEXP操作符


但有GLOB比LIKE更先进一点。

I am trying to fetch entries from a SQLiteDatabase in an Android program using the query function using the selection parameter. I have had success with simple pattern matching using the SQLite's LIKE and the % wildcard. Now I want to do more complex pattern matching using regular expressions.

According to the SQLite website, for the REGEXP operator to function, it must be user defined. Has anyone had any success creating use defined SQLite functions for Android's SQLiteDatabase? Or has anyone found another way to use regular expressions when searching through strings in a database?

解决方案

As described here

The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If a application-defined SQL function named "regexp" is added at run-time, that function will be called in order to implement the REGEXP operator.

But there is GLOB which is little more advanced than LIKE.

这篇关于查询Android的SQLiteDatabase使用正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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