Re: Regexp matching: bug or operator error? - Mailing list pgsql-general

From gnari
Subject Re: Regexp matching: bug or operator error?
Date
Msg-id 01c601c4d1bb$d4df25a0$0100000a@wp2000
Whole thread Raw
In response to Regexp matching: bug or operator error?  (Ken Tanzer <ktanzer@desc.org>)
List pgsql-general
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



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Regexp matching: bug or operator error?
Next
From:
Date:
Subject: Re: Upcoming Changes to News Server ...