pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: gnari <gnari@simnet.is>
To: Ken Tanzer <ktanzer@desc.org>
To: pgsql-general@postgresql.org
Subject: Re: Regexp matching:  bug or operator error?
Date: Wed, 24 Nov 2004 00:23:33 -0000
Message-ID: <01c601c4d1bb$d4df25a0$0100000a@wp2000> (raw)
References: <41A3C6C6.2090605@desc.org>

From: "Ken Tanzer" <ktanzer@desc.org>


> Using Postgres V. 7.4.1, the following query:
>
>     SELECT substring('X12345X' FROM '.*?([0-9]{1,5}).*?');
>
> Returns '1'.  I would expect it to return '12345'.  Is this a bug, or am
> I missing something?  Thanks.

the results of mixing greedy and non-greedy repetitions can be difficult to
predict.

try SELECT substring('X12345X' FROM '\\D*(\\d{1,5}).*?');

gnari





view thread (10+ messages)  latest in thread

Message-ID: <01c601c4d1bb$d4df25a0$0100000a@wp2000>
Permalink:  ../01c601c4d1bb$d4df25a0$0100000a@wp2000/
Also on:    postgresql.org/message-id/01c601c4d1bb$d4df25a0$0100000a@wp2000

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: gnari@simnet.is, ktanzer@desc.org, pgsql-general@postgresql.org
  Subject: Re: Regexp matching:  bug or operator error?
  In-Reply-To: <01c601c4d1bb$d4df25a0$0100000a@wp2000>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox