Re: POSIX-style regular expressions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: POSIX-style regular expressions
Дата
Msg-id 19730.1031670915@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: POSIX-style regular expressions  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Stephan Szabo <sszabo@megazone23.bigpanda.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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: POSIX-style regular expressions
Следующее
От: "Michael Paesold"
Дата:
Сообщение: Rules and Triggers