Re: Why this regexp matches?!

Поиск
Список
Период
Сортировка
От Szymon Guz
Тема Re: Why this regexp matches?!
Дата
Msg-id CAFjNrYvOVm98tp=RcxnR95MCKKLQ=9ajXVw3F84exK=+ZLjZoA@mail.gmail.com
обсуждение исходный текст
Ответ на Why this regexp matches?!  (hubert depesz lubaczewski <depesz@depesz.com>)
Ответы Re: Why this regexp matches?!
Список pgsql-general


On 4 February 2012 09:46, hubert depesz lubaczewski <depesz@depesz.com> wrote:
select 'depesz depeszx depesz' ~ E'^(.*)( \\1)+$';

what's worse:
$ select regexp_replace( 'depesz depeszx depesz', E'^(.*)( \\1)+$', E'\\1' );
 regexp_replace
────────────────
 depesz
(1 row)

I know that Pg regexps are limited, but even grep's regexps match this
correctly:

=$ printf 'depesz depesz depesz\ndepesz depeszx depesz\n' | grep -E '^(.*)( \1)+$';
depesz depesz depesz

Best regards,

depesz


Hi,
some time ago I hit the same problem, however the solution was a little bit tricky. I didn't have time to investigate it, but this works:

postgres@postgres:5840=#  select regexp_replace( 'depesz depeszx depesz', E'^(.*)( \\\\1)+$', E'\\\\1' );
    regexp_replace     
-----------------------
 depesz depeszx depesz
(1 row)


regards
Szymon

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

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Why this regexp matches?!
Следующее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: Why this regexp matches?!