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-18 23:25:24
Message-ID: 13780.1205882724@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Rui Martins" <Rui(dot)Martins(at)pdmfc(dot)com> writes:
> Description:        Incorrect  RegExp substring Output

>        SUBSTRING( BedNo FROM '^[[:digit:]]+[a-zA-Z]*(:[[:digit:]]+)?$' )

Interesting.  It had never occurred to me that it's possible for the
whole pattern to have a match when some parenthesized subexpression
has no match.  On investigation, Tcl's regex library seems to get
this right, but textregexsubstr() doesn't.  Will fix.

> I would expect the result for BedNumber to be either NULL or the EMPTY
> String, and the later seems more logical.

It's going to be null.  Your example has no match to the parenthesized
substring --- a match would have to include a colon and some digits, no?

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: kusumDate: 2008-03-19 05:33:45
Subject: BUG #4046: Error on connection
Previous:From: Chan, Keith (LESA IT)Date: 2008-03-18 20:38:05
Subject: Re: BUG #4041: error in Application Stack Builder

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