pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SIMILAR TO
3+ messages / 2 participants
[nested] [flat]

* SIMILAR TO
@ 2010-10-16 14:26  Rommel the iCeMAn <icecrew@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Rommel the iCeMAn @ 2010-10-16 14:26 UTC (permalink / raw)
  To: pgsql-sql

Hi guys,

I use the following code to detect alphanumeric strings:

IF _my_variable SIMILAR TO '^[a-zA-Z0-9]+$' THEN
        // do stuff here
END IF;

In pg8.4 this worked perfectly. I upgraded to pg9.0 and it no longer
works. From the release notes it appears that the behavior of SIMILAR
TO has changed in pg9.0. My question is, how do I modify my code so
that it works in 9.0?

Thanks in advance.
Rommel.



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

* Re: SIMILAR TO
@ 2010-10-16 14:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Rommel the iCeMAn <icecrew@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2010-10-16 14:30 UTC (permalink / raw)
  To: Rommel the iCeMAn <icecrew@gmail.com>; +Cc: pgsql-sql

Rommel the iCeMAn <icecrew@gmail.com> writes:
> I use the following code to detect alphanumeric strings:

> IF _my_variable SIMILAR TO '^[a-zA-Z0-9]+$' THEN
>         // do stuff here
> END IF;

> In pg8.4 this worked perfectly. I upgraded to pg9.0 and it no longer
> works. From the release notes it appears that the behavior of SIMILAR
> TO has changed in pg9.0. My question is, how do I modify my code so
> that it works in 9.0?

Drop the ^ and $; they are incorrect for SIMILAR TO.

			regards, tom lane



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

* Re: SIMILAR TO
@ 2010-10-16 16:23  Rommel the iCeMAn <icecrew@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Rommel the iCeMAn @ 2010-10-16 16:23 UTC (permalink / raw)
  To: pgsql-sql

Thank you very much. I figured it was something simple but I am not
proficient at regular expressions. Thanks again.

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Saturday, October 16, 2010 10:30 AM
To: Rommel the iCeMAn
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] SIMILAR TO

Rommel the iCeMAn <icecrew@gmail.com> writes:
> I use the following code to detect alphanumeric strings:

> IF _my_variable SIMILAR TO '^[a-zA-Z0-9]+$' THEN
>         // do stuff here
> END IF;

> In pg8.4 this worked perfectly. I upgraded to pg9.0 and it no longer
> works. From the release notes it appears that the behavior of SIMILAR
> TO has changed in pg9.0. My question is, how do I modify my code so
> that it works in 9.0?

Drop the ^ and $; they are incorrect for SIMILAR TO.

			regards, tom lane



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


end of thread, other threads:[~2010-10-16 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-16 14:26 SIMILAR TO Rommel the iCeMAn <icecrew@gmail.com>
2010-10-16 14:30 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-16 16:23 Re: SIMILAR TO Rommel the iCeMAn <icecrew@gmail.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