Re: regular expression question

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Joel Rodrigues <borgempath(at)Phreaker(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: regular expression question
Date: 2003-06-04 19:44:56
Message-ID: 20030604194456.63394.qmail@web20806.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- Joel Rodrigues <borgempath(at)Phreaker(dot)net> wrote:
> Hi,
> I'm trying to write a check on a column restricting
> the data to
> numerals from 0-9, commas, dashes '-' and single
> spaces. To
> allow the entry of something like "134-140,
> 310-312".
>
> I seem to have got everything but the single spaces.
>
> '^[0-9|,-]{0,10}$'

'^[0-9, -]*$'

The ordering inside the square brackets doesn't
matter, except that the "-" needs to be somewhere
where it cannot be mistaken for a range operator. The
conditions for that vary according to the
implementation, but I think the above should work with
PostgreSQL.

Change the "*" to "+" if you want to require something
to be entered.

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2003-06-04 19:48:16 Re: to copy a record
Previous Message Jan Wieck 2003-06-04 19:43:43 Re: speed w/ OFFSET/LIMIT