BUG #3645: regular expression back references seem broken

Поиск
Список
Период
Сортировка
От Eric Haszlakiewicz
Тема BUG #3645: regular expression back references seem broken
Дата
Msg-id 200710010043.l910hn3H021900@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #3645: regular expression back references seem broken  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #3645: regular expression back references seem broken  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      3645
Logged by:          Eric Haszlakiewicz
Email address:      erh+pgsql@swapsimple.com
PostgreSQL version: 8.2.5
Operating system:   NetBSD
Description:        regular expression back references seem broken
Details:

I was attempting to create a simple regular expression that uses back
references and I noticed some very odd behaviour.  This regexp is supposed
to match a string where all the characters are the same:

^(.)\1*$

If I try it, it doesn't work.  I would expect this to return false:

template1=# select 'xyz' ~ E'^(.)\\1*$';
 ?column?
----------
 t
(1 row)

But adding some extra parens does:
template1=# select 'xyz' ~ E'^(.)(\\1)*$';
 ?column?
----------
 f
(1 row)

As does changing the "." to an "x":

template1=# select 'xyz' ~ E'^(x)\\1*$';
 ?column?
----------
 f
(1 row)

As does forcing it to be a extended regular expression:


template1=# select 'xyz' ~ E'(?e)^(.)\\1*$';
 ?column?
----------
 f
(1 row)

The docs claim: "A single non-zero digit, not followed by another digit, is
always taken as a back reference."  (The note at the end of 9.7.3.3)

It's relatively easy to work around the problem, but it certainly led to a
fair bit of head scratching while trying to debug some code. :)

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Nasty tsvector can make dumps unrestorable
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3645: regular expression back references seem broken