Reputation: 1047
I want make query the field, In which there are no non numeric symbols.
Cursor c=context.getContentResolver().query(Uri.parse("content://mms-sms/canonical-addresses/"), new String[] {"address","_id"}, "replace("+"address"+", '[^0-9]','')"+" LIKE ?", new String[] {"%"+subaddress+"%"}, null);
But when i search in DB number format +7(888)888-88-88 by subaddress 8888888, cursor not moveToNext
Whats wrong?
Upvotes: 3
Views: 1325
Reputation: 152847
There's no regex support in replace
and Android sqlite does not provide an implementation of the regex
function either.
Your best option is to add another column which you use for searches and where the values are stripped of insignificant characters. You can use your regex for that in Java code.
If that is not an option and the set of special characters is small, you can use nested replaces:
replace(replace(replace(replace(address, '+', ''), '-', ''), '(', ''), ')', '')
But as you can see this gets cumbersome.
Upvotes: 5