# Sqlite regexp support

**URL:** <https://www.ruby-forum.com/t/sqlite-regexp-support/126148>\
**Category:** Ruby\
**Created:** [January 15, 2008, 9:02pm UTC](https://www.ruby-forum.com/t/sqlite-regexp-support/126148 "2008-01-15T21:02:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rolando\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d9b06d/32.png) [@Rolando\_A](https://www.ruby-forum.com/u/Rolando_A)\
**Post date:** [January 15, 2008, 9:02pm UTC](https://www.ruby-forum.com/t/sqlite-regexp-support/126148/1 "2008-01-15T21:02:17Z")

</div>

What’s the Right Way™ 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](http://somedomain.com)’

any hints?  
what should return the regexp function?
