wcdb icon indicating copy to clipboard operation
wcdb copied to clipboard

regexp查不到数据?

Open zedzhao opened this issue 6 years ago • 13 comments

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 查询是可以的~~是我使用方法不对吗?

zedzhao avatar Mar 29 '19 03:03 zedzhao

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

RingoD avatar Mar 29 '19 06:03 RingoD

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

zedzhao avatar Mar 29 '19 06:03 zedzhao

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

RingoD avatar Mar 29 '19 06:03 RingoD

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

zedzhao avatar Mar 29 '19 06:03 zedzhao

Show your code please.

RingoD avatar Mar 29 '19 06:03 RingoD

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"

zedzhao avatar Mar 29 '19 06:03 zedzhao

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

RingoD avatar Mar 29 '19 07:03 RingoD

T_T The requirements is to query by regex expression.

zedzhao avatar Mar 29 '19 07:03 zedzhao

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 avatar Mar 29 '19 07:03 RingoD

Currently, I have no idea.

RingoD avatar Mar 29 '19 07:03 RingoD

OK, Thanks T_T.

zedzhao avatar Mar 29 '19 07:03 zedzhao

i need regex too

wangpeiyan avatar May 07 '20 12:05 wangpeiyan

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

will0321 avatar Dec 10 '20 09:12 will0321