Skip site navigation (1) Skip section navigation (2)

Re: BUG #4044: Incorrect RegExp substring Output

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rui Martins" <Rui(dot)Martins(at)PDMFC(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4044: Incorrect RegExp substring Output
Date: 2008-03-19 18:56:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
"Rui Martins" <Rui(dot)Martins(at)PDMFC(dot)com> writes:
> Even though this can me though as argumentative, think about this expression:

> (something)?

> Will "match" with an empty string in the context of a full expression, and
> will return an EMPTY String. So by analogy, I would expect it, to return
> the same as a sub-expression when it actually has a "match" even if with
> an empty sub-string.

Uh, no, it *won't* match if there is not "something" in the string.

The behavior you are looking for is properly obtained this way:


This will return either "something" or an empty string (assuming
we have a globally successful match).  The point is there's a difference
between what X matches (or doesn't) and what X? matches.

			regards, tom lane

In response to


pgsql-bugs by date

Next:From: Heikki LinnakangasDate: 2008-03-19 22:16:34
Subject: Re: 8.3 can't convert cyrillic text from 'iso-8859-5' to other cyrillic 8-bit encoding
Previous:From: Rui MartinsDate: 2008-03-19 15:43:38
Subject: Re: BUG #4044: Incorrect RegExp substring Output

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group