From: | Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org> |
Subject: | RE: Match against a column of regexes? |
Date: | 2019-10-23 16:37:58 |
Message-ID: | BL0PR06MB4882B3762B1482B4CE450322E56B0@BL0PR06MB4882.namprd06.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Friday, October 18, 2019 1:27 AM
To: Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com>
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: Match against a column of regexes?
Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Irene Yeh | 2019-10-30 04:17:20 | Adding primary key on table with 3 billion records. |
Previous Message | Tom Lane | 2019-10-18 07:26:57 | Re: Match against a column of regexes? |