PostgreSQL query with an array of regexes
I recently wanted to query my Postgres database by matching a column based on an array of regular expressions:
To query where the column matches all expressions in the array:
select *
from my_table
where my_column ilike all (array['%some%', '%words%'])
To query where the column matches at least one, but not necessarily all, of the expressions in the array:
select *
from my_table
where my_column ilike any (array['%some%', '%words%'])
Tweet