Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regexp查不到数据? #487

Open
zedzhao opened this issue Mar 29, 2019 · 13 comments
Open

regexp查不到数据? #487

zedzhao opened this issue Mar 29, 2019 · 13 comments

Comments

@zedzhao
Copy link

zedzhao commented Mar 29, 2019

The language of WCDB

Objective-C,

The version of WCDB

v1.0.5

The platform of WCDB

iOS

The installation of WCDB

Cocoapods,

What's the issue?

regexp操作符如何使用
用regexp("[2-5]") 无法匹配到数据, 直接使用sql 查询是可以的~~是我使用方法不对吗?

@RingoD
Copy link
Collaborator

RingoD commented Mar 29, 2019

Please provide the whole data you used or a sample project for us.

@zedzhao
Copy link
Author

zedzhao commented Mar 29, 2019

Error Message:
[WCDB][ERROR]Code:1, Type:SQLite, Tag:0, Op:3, ExtCode:1, Msg:no such function: REGEXP,

@RingoD
Copy link
Collaborator

RingoD commented Mar 29, 2019

As it said, there is not function named REGEXP in SQLite.

@zedzhao
Copy link
Author

zedzhao commented Mar 29, 2019

Then how to use 'create_function‘ in WCDB to create regexp?

@RingoD
Copy link
Collaborator

RingoD commented Mar 29, 2019

Show your code please.

@zedzhao
Copy link
Author

zedzhao commented Mar 29, 2019

WCDB version is 1.0.6.1
NSArray *foots = [[DatabaseContext db] getObjectsOfClass:FootprintItem.class fromTable:[self tableName] where: FootprintItem.link.regexp(@"[2-5]")] ;

This is the one row data
id link time title
"207" "http://baidu_206.com" "20190328162124" "title_206_206"

@RingoD
Copy link
Collaborator

RingoD commented Mar 29, 2019

By default, REGEXP is not created by SQLite.
What would you like to do by REGEXP? What is the demand?

@zedzhao
Copy link
Author

zedzhao commented Mar 29, 2019

T_T The requirements is to query by regex expression.

@RingoD
Copy link
Collaborator

RingoD commented Mar 29, 2019

According the sqlite official doc,

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 an application-defined SQL function named "regexp" is added at run-time, then the "X REGEXP Y" operator will be implemented as a call to "regexp(Y,X)".

I think we should add a builtin REGEXP in the future version.

@RingoD
Copy link
Collaborator

RingoD commented Mar 29, 2019

Currently, I have no idea.

@zedzhao
Copy link
Author

zedzhao commented Mar 29, 2019

OK, Thanks T_T.

@wangpeiyan
Copy link

i need regex too

@will0321
Copy link

我用REGEXP也查不出来。啥情况

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants