Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

greedy or not? regexps...


  • From: "Anton Melser" <melser(dot)anton(at)gmail(dot)com>
  • To: pgsql-general(at)postgresql(dot)org
  • Subject: greedy or not? regexps...
  • Date: Fri, 23 Feb 2007 10:11:55 +0100
  • Message-id: <92d3a4950702230111v5abcde0fg96117486623306db(at)mail(dot)gmail(dot)com>

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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group