regex help wanted

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: regex help wanted
Date: 2013-04-25 14:11:27
Message-ID: 20130425141127.GH3802@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I am in the process of converting some TEXT data which I try
to identify by regular expression.

What I don't understand is: Why does the following return a
substring ?

select substring ('junk $<allergy::test::99>$ junk' from '\$<[^<]+?::[^:]+?>\$');

I would have thought the '::[^:]+?>' part should have meant

after two ":"s
match at least one character
except any further ":"s
until the next ">"

I don't find the flaw in my thinking. Can anyone help ?

(Sure, it is not PostgreSQL-specific yet I need to run this
in PostgreSQL on data migration.)

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andres Freund 2013-04-25 14:16:23 Re: Replication terminated due to PANIC
Previous Message Merlin Moncure 2013-04-25 13:59:51 Re: pgdump error "Could not open file pg_clog/0B8E: No such file or directory"