pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Regular expression problem
7+ messages / 4 participants
[nested] [flat]

* Regular expression problem
@ 2003-10-23 18:12 Matias Surdi <matiass@interlap.com.ar>
  2003-10-23 19:44 ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  0 siblings, 1 reply; 7+ messages in thread

From: Matias Surdi @ 2003-10-23 18:12 UTC (permalink / raw)
  To: pgsql-sql

Hi... I'm dealing with a regular expression in a check constraint for 
many days.... i'm stuck with this...
what I'm doing is adding a check to an existing table on a field called 
codigoex1 (varchar(9) )
check (codigoex1 ~* '[a-z]{2,2}')

and I can't get it to work!
I want to validate only input data such as "ar" "Us" "bR" and NOT 
something like "rum" "a"
the previous reg. expr. only works like it were ~* '[a-z]{2}' , so, it 
ignores the maximum length.

Tanks a lot!








^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Regular expression problem
  2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
@ 2003-10-23 19:44 ` Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 17:04   ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  0 siblings, 1 reply; 7+ messages in thread

From: Manuel Sugawara @ 2003-10-23 19:44 UTC (permalink / raw)
  To: Matias Surdi <matiass@interlap.com.ar>; +Cc: pgsql-sql

Matias Surdi <matiass@interlap.com.ar> writes:

> Hi... I'm dealing with a regular expression in a check constraint for many
> days.... i'm stuck with this...
> 
> what I'm doing is adding a check to an existing table on a field called
> codigoex1 (varchar(9) )
> 
> check (codigoex1 ~* '[a-z]{2,2}')
> 
> and I can't get it to work!
> I want to validate only input data such as "ar" "Us" "bR" and NOT something
> like "rum" "a"

Use something like '^[a-z]{2}$'

Regards,
Manuel.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Regular expression problem
  2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
  2003-10-23 19:44 ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
@ 2003-10-24 17:04   ` Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 16:37     ` Re: Regular expression problem scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Manuel Sugawara @ 2003-10-24 17:04 UTC (permalink / raw)
  To: Matias Surdi <matiass@interlap.com.ar>; +Cc: pgsql-sql

Matias Surdi <matiass@interlap.com.ar> writes:

> Manuel Sugawara wrote:
> >Use something like '^[a-z]{2}$'
> 
> so, is this a bug????

No it is not. The sintax you are using is not supported.

Regards,
Manuel.





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Regular expression problem
  2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
  2003-10-23 19:44 ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 17:04   ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
@ 2003-10-24 16:37     ` scott.marlowe <scott.marlowe@ihs.com>
  2003-10-24 18:16       ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 18:43       ` Re: Regular expression problem Jeff Eckermann <jeff_eckermann@yahoo.com>
  0 siblings, 2 replies; 7+ messages in thread

From: scott.marlowe @ 2003-10-24 16:37 UTC (permalink / raw)
  To: Manuel Sugawara <masm@fciencias.unam.mx>; +Cc: Matias Surdi <matiass@interlap.com.ar>; pgsql-sql

On 24 Oct 2003, Manuel Sugawara wrote:

> Matias Surdi <matiass@interlap.com.ar> writes:
> 
> > Manuel Sugawara wrote:
> > >Use something like '^[a-z]{2}$'
> > 
> > so, is this a bug????
> 
> No it is not. The sintax you are using is not supported.

It certainly seems to work in Postgresql 7.4 beta 4:

create table test2 (info text);
CREATE TABLE
insert into test2 values ('ab');
INSERT 109169538 1
insert into test2 values ('abc');
INSERT 109169539 1

marl8412=# select * from test2 where info ~ '^[a-z]{2}$';
 info
------
 ab

Or was there more to that message I wasn't getting?




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Regular expression problem
  2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
  2003-10-23 19:44 ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 17:04   ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 16:37     ` Re: Regular expression problem scott.marlowe <scott.marlowe@ihs.com>
@ 2003-10-24 18:16       ` Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 17:44         ` Re: Regular expression problem scott.marlowe <scott.marlowe@ihs.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Manuel Sugawara @ 2003-10-24 18:16 UTC (permalink / raw)
  To: scott.marlowe <scott.marlowe@ihs.com>; +Cc: Matias Surdi <matiass@interlap.com.ar>; pgsql-sql

"scott.marlowe" <scott.marlowe@ihs.com> writes:

> It certainly seems to work in Postgresql 7.4 beta 4:
> 
> create table test2 (info text);
> CREATE TABLE
> insert into test2 values ('ab');
> INSERT 109169538 1
> insert into test2 values ('abc');
> INSERT 109169539 1
> 
> marl8412=# select * from test2 where info ~ '^[a-z]{2}$';
>  info
> ------
>  ab
> 
> Or was there more to that message I wasn't getting?

He was trying to use '[a-z]{2,2}', which doesn't work in PostgreSQL.

Regards,
Manuel.




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Regular expression problem
  2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
  2003-10-23 19:44 ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 17:04   ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 16:37     ` Re: Regular expression problem scott.marlowe <scott.marlowe@ihs.com>
  2003-10-24 18:16       ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
@ 2003-10-24 17:44         ` scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 0 replies; 7+ messages in thread

From: scott.marlowe @ 2003-10-24 17:44 UTC (permalink / raw)
  To: Manuel Sugawara <masm@fciencias.unam.mx>; +Cc: Matias Surdi <matiass@interlap.com.ar>; pgsql-sql

On 24 Oct 2003, Manuel Sugawara wrote:

> "scott.marlowe" <scott.marlowe@ihs.com> writes:
> 
> > It certainly seems to work in Postgresql 7.4 beta 4:
> > 
> > create table test2 (info text);
> > CREATE TABLE
> > insert into test2 values ('ab');
> > INSERT 109169538 1
> > insert into test2 values ('abc');
> > INSERT 109169539 1
> > 
> > marl8412=# select * from test2 where info ~ '^[a-z]{2}$';
> >  info
> > ------
> >  ab
> > 
> > Or was there more to that message I wasn't getting?
> 
> He was trying to use '[a-z]{2,2}', which doesn't work in PostgreSQL.

Oh, ok.  Thanks.




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Regular expression problem
  2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
  2003-10-23 19:44 ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 17:04   ` Re: Regular expression problem Manuel Sugawara <masm@fciencias.unam.mx>
  2003-10-24 16:37     ` Re: Regular expression problem scott.marlowe <scott.marlowe@ihs.com>
@ 2003-10-24 18:43       ` Jeff Eckermann <jeff_eckermann@yahoo.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Jeff Eckermann @ 2003-10-24 18:43 UTC (permalink / raw)
  To: scott.marlowe <scott.marlowe@ihs.com>; +Cc: Matias Surdi <matiass@interlap.com.ar>; pgsql-sql

7.4 uses a completely new regex engine, so comparisons
with that will not be valid anyway.
Pre-7.4 regex behaviour is all documented:
Users Guide -> Functions & Operators -> Pattern
Matching

--- "scott.marlowe" <scott.marlowe@ihs.com> wrote:
> On 24 Oct 2003, Manuel Sugawara wrote:
> 
> > Matias Surdi <matiass@interlap.com.ar> writes:
> > 
> > > Manuel Sugawara wrote:
> > > >Use something like '^[a-z]{2}$'
> > > 
> > > so, is this a bug????
> > 
> > No it is not. The sintax you are using is not
> supported.
> 
> It certainly seems to work in Postgresql 7.4 beta 4:
> 
> create table test2 (info text);
> CREATE TABLE
> insert into test2 values ('ab');
> INSERT 109169538 1
> insert into test2 values ('abc');
> INSERT 109169539 1
> 
> marl8412=# select * from test2 where info ~
> '^[a-z]{2}$';
>  info
> ------
>  ab
> 
> Or was there more to that message I wasn't getting?
> 
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
>     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2003-10-24 18:43 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-23 18:12 Regular expression problem Matias Surdi <matiass@interlap.com.ar>
2003-10-23 19:44 ` Manuel Sugawara <masm@fciencias.unam.mx>
2003-10-24 17:04   ` Manuel Sugawara <masm@fciencias.unam.mx>
2003-10-24 16:37     ` scott.marlowe <scott.marlowe@ihs.com>
2003-10-24 18:16       ` Manuel Sugawara <masm@fciencias.unam.mx>
2003-10-24 17:44         ` scott.marlowe <scott.marlowe@ihs.com>
2003-10-24 18:43       ` Jeff Eckermann <jeff_eckermann@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox