Is there a way to search via Regex pattern in ActiveRecord? I have a collection of products. I'll like to search these products based on their sku column meeting a number of patterns.
SKUs having single letters from [A-Z] should be considered premium products
SKUs having single letters [A-Z] and a digit[0-9] should be considered standard products
SKUs having double letters and a digit [0-9] should be considered flash products
Here is a pseudo-code of what I need:
product.sku ~= /[A-Z]$/ => Premium Products
product.sku ~= /[A-Z][0-9]$/ => Standard Products
product.sku ~= /[A-Z]{2}[0-9]$/ => Flash products
I don't want to use ruby's select filtering. Is this possible via active-record?