Re: Literal dash in regular expression brackets - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Literal dash in regular expression brackets
Date
Msg-id 20020909144703.GA2030@wolff.to
Whole thread Raw
In response to Literal dash in regular expression brackets  (Steve <steve@infinity.rhythm.cx>)
List pgsql-general
On Thu, Sep 05, 2002 at 14:39:26 -0400,
  Steve <steve@infinity.rhythm.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.]+$' )

pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: starting with linux as another user...
Next
From: Lee Kindness
Date:
Subject: SQL: how to find if a table exists?