Unix Technical Forum

BUG #1686: Regular expression problem

This is a discussion on BUG #1686: Regular expression problem within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 1686 Logged by: Halley Pacheco de Oliveira Email address: halleypo@yahoo.com.br ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:53 AM
Halley Pacheco de Oliveira
 
Posts: n/a
Default BUG #1686: Regular expression problem


The following bug has been logged online:

Bug reference: 1686
Logged by: Halley Pacheco de Oliveira
Email address: halleypo@yahoo.com.br
PostgreSQL version: 7.4 and 8.0
Operating system: Linux and Windows
Description: Regular expression problem
Details:

SELECT '200.222.197.219' SIMILAR TO
'([[:alnum:]_]+).([[:alnum:]_]+).([[:alnum:]_]+)';

?column?
----------
t
(1 row)

SELECT '200.222.197.219' ~
'([[:alnum:]_]+)\\.([[:alnum:]_]+)\\.([[:alnum:]_]+)';

?column?
----------
t
(1 row)

SELECT '200.222.197.219' SIMILAR TO '([\\w-]+).([\\w-]+).([\\w]+)';

?column?
----------
f
(1 row)

SELECT '200.222.197.219' ~ '([\\w-]+)\\.([\\w-]+)\\.([\\w]+)';

?column?
----------
t
(1 row)

Why does the third query gives a different output? It is not exactly the
same as the first query?

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:53 AM
Alvaro Herrera
 
Posts: n/a
Default Re: BUG #1686: Regular expression problem

On Sat, May 28, 2005 at 11:22:12PM +0100, Halley Pacheco de Oliveira wrote:

> [third query:]
>
> SELECT '200.222.197.219' SIMILAR TO '([\\w-]+).([\\w-]+).([\\w]+)';
>
> ?column?
> ----------
> f
> (1 row)
>
> Why does the third query gives a different output? It is not exactly the
> same as the first query?


Hmm, you are aware that SIMILAR TO is defined by the SQL standard, so
the rules are not exactly the same as POSIX regexes, right? I guess the
\w character class (a Perl-ism, I think) is not defined for SIMILAR TO.

(Note that our ~ regexes are powered by code of Tcl's heritage, so you
could check Tcl's manual on regexes.)


Anyway I wonder why you are trying to use regular expressions when you
could be using the INET type; maybe the INET input function if it came
to it.

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"Limítate a mirar... y algun día veras"

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 09:53 AM
Bruno Wolff III
 
Posts: n/a
Default Re: BUG #1686: Regular expression problem

On Tue, May 31, 2005 at 11:15:23 -0400,
Alvaro Herrera <alvherre@surnet.cl> wrote:
>
> (Note that our ~ regexes are powered by code of Tcl's heritage, so you
> could check Tcl's manual on regexes.)


Aren't they based directly on Henry Spencer's code?

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 09:53 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #1686: Regular expression problem

Bruno Wolff III <bruno@wolff.to> writes:
> On Tue, May 31, 2005 at 11:15:23 -0400,
> Alvaro Herrera <alvherre@surnet.cl> wrote:
>> (Note that our ~ regexes are powered by code of Tcl's heritage, so you
>> could check Tcl's manual on regexes.)


> Aren't they based directly on Henry Spencer's code?


It *is* Henry's code, lock stock and barrel, inherited by way of Tcl.
I'm not sure how much Henry is involved in maintaining the Tcl regex
engine anymore, but he's certainly the original author.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com