Re: POSIX-style regular expressions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Goran Buzic <goran(dot)buzic(at)hep(dot)hr>, pgsql-sql(at)postgresql(dot)org
Subject: Re: POSIX-style regular expressions
Date: 2002-09-10 15:15:15
Message-ID: 19730.1031670915@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> On Tue, 10 Sep 2002, Goran Buzic wrote:
>> id1 char(6) NOT NULL CHECK(id1 ~* '^([0-9]{1,2}\.){2}$'),

> Bad column type choice. char(6) is space padded, so 1.2. looks like
> "1.2. ". For me, 12.12. works, but any shorter one fails. Unless
> you need space padding elsewhere, you may just want to use varchar(6);

Also, the backslash has to be doubled to get through the string literal
parser, so what you really want is

id1 varchar(6) NOT NULL CHECK(id1 ~* '^([0-9]{1,2}\\.){2}$'),

else it will accept values you don't want...

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Paesold 2002-09-10 18:52:55 Rules and Triggers
Previous Message Ross J. Reedstrom 2002-09-10 15:13:39 Re: POSIX-style regular expressions