pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dawid Kuroczko <qnex42@gmail.com>
To: Filip RembiaƂkowski <plk.zuber@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Finding broken regex'es
Date: Wed, 3 Oct 2007 17:41:04 +0200
Message-ID: <758d5e7f0710030841q68e332f6xd44a2675dd0f3994@mail.gmail.com> (raw)
In-Reply-To: <92869e660710030740j238eca69n24a9d1febc40df63@mail.gmail.com>
References: <20071002202313.GB18506@nibiru.local>
	<758d5e7f0710030636m63bec244paa6cbaf04e66b3d2@mail.gmail.com>
	<92869e660710030740j238eca69n24a9d1febc40df63@mail.gmail.com>

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


view thread (8+ messages)

Message-ID: <758d5e7f0710030841q68e332f6xd44a2675dd0f3994@mail.gmail.com>
Permalink:  ../758d5e7f0710030841q68e332f6xd44a2675dd0f3994@mail.gmail.com/
Also on:    postgresql.org/message-id/758d5e7f0710030841q68e332f6xd44a2675dd0f3994@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: qnex42@gmail.com, plk.zuber@gmail.com
  Subject: Re: Finding broken regex'es
  In-Reply-To: <758d5e7f0710030841q68e332f6xd44a2675dd0f3994@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox