greedy or not? regexps... - Mailing list pgsql-general

From Anton Melser
Subject greedy or not? regexps...
Date
Msg-id 92d3a4950702230111v5abcde0fg96117486623306db@mail.gmail.com
Whole thread Raw
Responses Re: greedy or not? regexps...  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,
I am trying to understand the function substring.

Here:
select SUBSTRING(cit1.summary, '=([0-9]*)') from cms_items cit1
where cit1.summary ~* '.*linkadministration.*[0-9]*';

gives me two empty strings and

select SUBSTRING(cit1.summary, '=([0-9]{1,10})') from cms_items cit1
where cit1.summary ~* '.*linkadministration.*[0-9]*';

gives me the right values.

However, bizarrely,

select SUBSTRING(ban1.url_id, '=([0-9]*)')
from banner ban1
where ban1.url_id ~* '.*linkadministration.*[0-9]*';

select SUBSTRING(ban1.url_id, '=([0-9]{1,10})')
from banner ban1
where ban1.url_id ~* '.*linkadministration.*[0-9]*';

Both give me the same result!!! The difference being that in case two
the numbers I am catching are at the end of the strings and in case 1
in the middle. Is this normal? Which is correct?
Cheers
Anton

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: complex referential integrity constraints
Next
From: "Ben Edwards"
Date:
Subject: Writing oracle/postgress generic SQL