RE: Match against a column of regexes?

Stephen Froehlich <[email protected]> Wed, 23 Oct 2019 16:37:58 +0000
Newsgroups gmane.comp.db.postgresql.novice
Message-ID <BL0PR06MB4882B3762B1482B4CE450322E56B0@BL0PR06MB4882.namprd06.prod.outlook.com>
Actually, all I needed to do was to reverse the input text and the column name in the query:

	SELECT DISTINCT group_id FROM logins WHERE '[user_email]' ~* email_regex;

--Stephen

-----Original Message-----
From: Tom Lane <[email protected]> 
Sent: Friday, October 18, 2019 1:27 AM
To: Stephen Froehlich <[email protected]>
Cc: [email protected]
Subject: Re: Match against a column of regexes?

Stephen Froehlich <[email protected]> writes:
> I was wondering if there was an elegant way to match a given string against a column of regexes within PostgreSQL?  I'm only working with a few tens of lines, so I can read them all into R and examine them 1-by-1, but I thought I would ask.

Something like

	... WHERE mystring ~ ANY (SELECT regex FROM regexes)

should do.

			regards, tom lane