2 Votes Vote

Regular expressions in a sql database

Posted by topdog 251 days ago Questions| regular table database All

I have a database table with a column where every entry is a regular expression. For example, the rows in my table look like this:

table: email_address_templates email_address: /*.google.com/ email_address: /*.reddit.com/ email_address: /*.ac.uk/

I want to be able to search through this table, and find if a particular string matches one of the regular expressions.

In ruby, it would look like this:

EmailAddressTemplate.all.select do |ea|
  ea.match "james@something.else.ac.uk"
end

I am wondering if there is a way to do a similar thing in pure mysql.

Discuss Bury


Who Voted for this Question