Re: Literal '-' in regular expression bracket sets

From: Steve <s-psql(at)rhythm(dot)cx>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Literal '-' in regular expression bracket sets
Date: 2002-09-05 19:00:46
Message-ID: 20020905150046.A30769@infinity.rhythm.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 05, 2002 at 11:50:55AM -0700, Stephan Szabo wrote:
>
> On Thu, 5 Sep 2002, Steve 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\-\.]+$' )
> > );
>
> I think you might have to move the dash to the beginning of the character
> set. I can't find an easy way to make it happy otherwise. I believe the
> '.' doesn't need to be escaped.

That worked - thanks!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2002-09-05 19:48:50 Re: 7.3b1 installation
Previous Message Tom Lane 2002-09-05 18:56:16 Re: Literal '-' in regular expression bracket sets