RE: Match against a column of regexes? - Mailing list pgsql-novice

From Stephen Froehlich
Subject RE: Match against a column of regexes?
Date
Msg-id BL0PR06MB4882B3762B1482B4CE450322E56B0@BL0PR06MB4882.namprd06.prod.outlook.com
Whole thread Raw
In response to Re: Match against a column of regexes?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
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 <tgl@sss.pgh.pa.us>
Sent: Friday, October 18, 2019 1:27 AM
To: Stephen Froehlich <s.froehlich@cablelabs.com>
Cc: pgsql-novice@lists.postgresql.org
Subject: Re: Match against a column of regexes?

Stephen Froehlich <s.froehlich@cablelabs.com> writes:
> I was wondering if there was an elegant way to match a given string against a column of regexes within PostgreSQL?
I'monly 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



pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Match against a column of regexes?
Next
From: Irene Yeh
Date:
Subject: Adding primary key on table with 3 billion records.