public inbox for [email protected]  
help / color / mirror / Atom feed
From: gnari <[email protected]>
To: Ken Tanzer <[email protected]>
To: [email protected]
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: <[email protected]>

From: "Ken Tanzer" <[email protected]>


> 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 (12+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox