1

I've seen that sqlite by default does not come with REGEXP defined (links: link link2) but I can't find any information about this regarding the android version of sqlite where the contacts are saved.

I've tried this following:

final Cursor cursor = contentResolver.query(Contacts.CONTENT_URI, 
                PROJECTION_SEARCH_FOR_CONTACT, 
                "upper(" + Data.DISPLAY_NAME + ") REGEXP \\b " + "123" + "\\b",     
                null,
                null); 

but I'm getting:

05-23 04:28:09.562: W/System.err(24447): android.database.sqlite.SQLiteException: unrecognized token: "\" (code 1): , while compiling: SELECT _id, display_name, photo_id, name_raw_contact_id FROM view_contacts WHERE ((1)) AND ((upper(display_name) REGEXP \b  123 \b))

As I'm not proeficient with regex, I'm not sure if this is due to Contacts Storage database (SQLite) not having regexp defined or my syntax is wrong.

Can someone clarify me?

Community
  • 1
  • 1
dazito
  • 7,740
  • 15
  • 75
  • 117
  • There are two things. firstly I just want to check you didn't want to match the word boundaries around `123` which would be `\b123\b` as you appear to have a space in there. secondly, I think you need to put that regexp in a string so that it can be matched against like so: `REGEXP '\b 123 \b'` – Mike H-R May 23 '14 at 16:11
  • Thanks for you comment, changing it accordingly to your comment still get the same exception. – dazito May 26 '14 at 07:59

0 Answers0