making regex query work in PostgreSQL