Re: Literal dash in regular expression brackets

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Steve <steve(at)infinity(dot)rhythm(dot)cx>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Literal dash in regular expression brackets
Date: 2002-09-09 14:47:03
Message-ID: 20020909144703.GA2030@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 05, 2002 at 14:39:26 -0400,
Steve <steve(at)infinity(dot)rhythm(dot)cx> wrote:
>
> I'm trying to place a literal '-' in a bracketed character set in a regular
> expression for a check constraint. I am currently escaping it with a '\',
> however, it still winds up in the table definition as a non-literal dash and
> is interpreted as a character range. For instance:
>
> CREATE TABLE retest
> (
> hostname VARCHAR(100) CHECK (hostname ~ '^[a-zA-Z0-9\-\.]+$' )
> );

It should be:
hostname VARCHAR(100) CHECK (hostname ~ '^[-a-zA-Z0-9.]+$' )

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Ploski 2002-09-09 14:48:46 Re: this is postgresql question..how do i drop unique constraint on a column?
Previous Message Richard Huxton 2002-09-09 14:43:50 Re: SQL: how to find if a table exists?