Re: Regex on field value

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mike Martin <redtux1(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Regex on field value
Date: 2018-04-14 21:12:25
Message-ID: d4db202a-82a0-2d6d-c8d4-eee479702d61@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/14/2018 02:06 PM, David G. Johnston wrote:
> On Saturday, April 14, 2018, Mike Martin <redtux1(at)gmail(dot)com
> <mailto:redtux1(at)gmail(dot)com>> wrote:
>
> Is this possible, eg
> Substring(field, regex include other field name)

Something like?:

select substring(link_key from '^' || c_id ), link_key, c_id from
projection where link_key != 'no_key' limit 10;

substring | link_key | c_id
-----------+-------------+--------
6RPLF | 6RPLF-1646 | 6RPLF
6RPLF | 6RPLF-1646 | 6RPLF
6RPLF | 6RPLF-1646 | 6RPLF
6RPLF | 6RPLF-1646 | 6RPLF
4RPLF | 4RPLF-1694 | 4RPLF
10CEHB | 10CEHB-2628 | 10CEHB
10CEHB | 10CEHB-2628 | 10CEHB
10CEHB | 10CEHB-2628 | 10CEHB
10CEHB | 10CEHB-1698 | 10CEHB
1GPLF | 1GPLF-1704 | 1GPLF
(10 rows)

>
>
> Your example doesn't make sense but if you are asking whether a regular
> expression can be stored in a column the answer is yes - though it's
> nothing but a text value with runtime limitations.
>
> David J.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A A 2018-04-15 08:25:05 Can a broken Postgresql data directory be reconstructed without losing data?
Previous Message David G. Johnston 2018-04-14 21:06:36 Re: Regex on field value