Why this regexp matches?!

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Why this regexp matches?!
Date: 2012-02-04 08:46:30
Message-ID: 20120204084630.GA8183@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Szymon Guz 2012-02-04 08:54:34 Re: Why this regexp matches?!
Previous Message John R Pierce 2012-02-04 07:49:22 Re: debugging the server[ module causes server cash]