sqlite regexp support

R

Rolando Abarca

What's the Right Way(tm) to implement regexp support in sqlite?
I'm doing this, but apparently it's not working:

db = SQLite3::Database.new("test.db")
db.results_as_hash = true
db.create_function('regexp', 2) do |func, v1, v2|
r = Regexp.new(v1.to_s)
if v2.to_s.match(r)
func.result = true
else
func.result = false
end
end

and i'm running a query like this:

select * from table where column REGEXP '(www\.)?somedomain.com'

any hints?
what should return the regexp function?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top