SQL substring is not a greedy regular expression

I have data like

http://www.linz.at/politik_verwaltung/32386.asp

stored in a text column. I thought non-greedy retrieval using

select substring(turl from '\..*?$') as ext from tdata

would give me .asp but instead it still ?greedelyleads to

 .linz.at/politik_verwaltung/32386.asp

How can I combine only with the last appearance of a point .?
Using Postgresql 9.3

+4
source share
2 answers

\.[^.]*$matches .followed by any number of non-dot characters followed by the end of the line:

# select substring('http://www.linz.at/politik_verwaltung/32386.asp' 
  from '\.[^.]*$');
 substring 
-----------
 .asp
(1 row)

, - , , - , .

+6

:

\.[\w]*$

:

word (\w), *, dot (\.) end of the string ($), . .

: , ..

+2

All Articles