Is there anyway in ruby on rails to make a query using regexp?
Asked
Active
Viewed 3,167 times
2
-
See my [answer on a similar question](http://stackoverflow.com/questions/6839204/how-to-turn-on-regexp-in-sqlite3-and-rails-3-1/8603393#8603393) that works for Rails3 as well. – mliebelt Dec 22 '11 at 11:43
1 Answers
6
I think it might depend on the database. I know in MySQL you can do something like:
Model.find(:conditions => "field REGEXP '.*'")
if you want a true regex, or you can use the LIKE syntax for similar string matching.
While it doesn't have regex, there's also a gem called MetaWhere that provides more advanced finder functionality.

Peter Brown
- 50,956
- 18
- 113
- 146