5

I want to run a query in SQLite with a regexp using Android. How do I do that?

Ravi
  • 34,851
  • 21
  • 122
  • 183

2 Answers2

5

Unfortunately it doesn't look like Android currently supplies a way for you to inject a user function into sqlite, which is what you'd need to make REGEXP work (specifically, you'd need a user function named regexp()) -- so you may have to select more broadly (with a LIKE condition that's broader than the regexp you want) and further distinguish "actual" result (those that really match the regexp you want) with java.util.regex in your application.

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
-3

Patterns are compiled regular expressions. In many cases, convenience methods such as String.matches, String.replaceAll and String.split will be preferable, but if you need to do a lot of work with the same regular expression, it may be more efficient to compile it once and reuse it. The Pattern class and its companion, Matcher, also offer more functionality than the small amount exposed by String.

http://developer.android.com/reference/java/util/regex/Pattern.html

Oh Danny Boy
  • 4,857
  • 8
  • 56
  • 88