Re: Regexp matching: bug or operator error?

From: "gnari" <gnari(at)simnet(dot)is>
To: "Ken Tanzer" <ktanzer(at)desc(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regexp matching: bug or operator error?
Date: 2004-11-24 00:23:33
Message-ID: 01c601c4d1bb$d4df25a0$0100000a@wp2000
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-general

From: "Ken Tanzer" <ktanzer(at)desc(dot)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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Ken Tanzer 2004-11-24 17:53:41 Re: Regexp matching: bug or operator error?
Previous Message Tom Lane 2004-11-24 00:15:18 Re: Regexp matching: bug or operator error?

Browse pgsql-general by date

  From Date Subject
Next Message terry 2004-11-24 00:40:18 Re: Upcoming Changes to News Server ...
Previous Message Tom Lane 2004-11-24 00:15:18 Re: Regexp matching: bug or operator error?