sqlite regexp support

Discussion in 'Ruby' started by Rolando Abarca, Jan 15, 2008.

  1. 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?

    --
    Rolando Abarca
    Phone: +56-9 97851962
    My Amazon Wish List: http://www.amazon.com/gp/registry/wishlist/3AGJOT5E6SIQB
     
    Rolando Abarca, Jan 15, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    252
  2. Daniel Fetchinson
    Replies:
    3
    Views:
    329
    Daniel Fetchinson
    Apr 22, 2008
  3. Carl Youngblood
    Replies:
    1
    Views:
    229
    Carl Youngblood
    Apr 9, 2005
  4. Replies:
    4
    Views:
    350
  5. Joao Silva
    Replies:
    16
    Views:
    363
    7stud --
    Aug 21, 2009
Loading...

Share This Page