Search Postgresql Archives

Re: Why this regexp matches?!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 4 February 2012 09:46, hubert depesz lubaczewski <depesz@xxxxxxxxxx> 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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux