Re: Finding broken regex'es - Mailing list pgsql-sql

From Dawid Kuroczko
Subject Re: Finding broken regex'es
Date
Msg-id 758d5e7f0710030841q68e332f6xd44a2675dd0f3994@mail.gmail.com
Whole thread Raw
In response to Re: Finding broken regex'es  ("Filip Rembiałkowski" <plk.zuber@gmail.com>)
Responses Accessing field of OLD in trigger
List pgsql-sql
On 10/3/07, Filip Rembiałkowski <plk.zuber@gmail.com> wrote:
> 2007/10/3, Dawid Kuroczko <qnex42@gmail.com>:
>
> > CREATE TABLE rx_check (
> >     rx text CHECK ('' ~ rx IN ('t','f'))
> > );
>
> wow. This is beautiful :)

Personally I would wrap it around DOMAIN, i.e.:

CREATE DOMAIN regex AS   text CHECK ('' ~ VALUE IN (TRUE,FALSE));

And then use 'regex' type instead of 'text'.  For a nice look&feel:

CREATE TABLE rx_test (   rx regex
);

qnex=>insert into rx_test values ('.*');
INSERT 0 1
qnex=>insert into rx_test values ('qwe');
INSERT 0 1
qnex=>insert into rx_test values ('aaa(aaa');
ERROR:  invalid regular expression: parentheses () not balanced

pgsql-sql by date:

Previous
From: "Filip Rembiałkowski"
Date:
Subject: Re: Finding broken regex'es
Next
From: "Hengky Lie"
Date:
Subject: Need help with CASE statement in Function