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